Categories
ASP

ASP: Find the length of a string using len and lenB function

my_string=”Welcome to MySite.com” Response.Write ( my_string ) Response.Write “Length of this string = ” & len(my_string) Response.Write “Number of bytes Required for this string = ” & lenB(my_string) The output of this will also show the number of bytes required. Here in this case it will print this: Welcome to MySite.com Length of this string […]

Categories
PHP

PHP: Expressions and Operators

Arithmetic Operators: + Addition Add two values – Subtraction Subtract the second value from the first * Multiplication Multiply two values / Division Divide the first value by the second % Modulus Divide the first value by the second and return only the remainder (for example, 7 % 5 yields 2) Comparison Operators: = = […]

Categories
SQL

SQL Select leftmost or rightmost characters from rows of data

SELECT left(item_num, 4) FROM flowers; If item_num = 754861 then the output will be: 7548 SELECT right(item_num, 4) FROM flowers; If item_num = 754861 then the output will be: 4861

Categories
PHP

eregi_replace() vs. ereg_replace()

Code: <?php $s = “Coding PHP is fun.”; print “ereg_replace(): ” . ereg_replace(“CODING”, “Learning”, $s) . “<br>”; print “eregi_replace(): ” . eregi_replace(“CODING”, “Learning”, $s); ?> Output: ereg_replace(): Coding PHP is fun. eregi_replace(): Learning PHP is fun. Explanation: eregi_replace() is case insensitive, while ereg_replace() is not.

Categories
HTML

HTML Special Characters

– &ndash; &#8211; en dash — &mdash; &#8212; em dash ¡ &iexcl; &#161; inverted exclamation ¿ &iquest; &#191; inverted question mark " &quot; &#34; quotation mark “ &ldquo; &#8220; left double curly quote ” &rdquo; &#8221; right double curly quote '   &#39; apostrophe (single quote) ‘ &lsquo; &#8216; left single curly quote ’ &rsquo; […]

Categories
PHP

Formatting money / currency using PHP

$formatted = number_format($number,2);