Home >> PHP - MySQL PHP with example codes - 1.2 [Page 5] Article by: Shelton Manage Friday, 22nd May, 2009
Usefull Strings-Specific Functions
PHP has a slew of usefull string specific functions. Which you'll see future.
Ec: To see how long a string is ( how many characters it containd), use strlen() ; $num = strlen($string);
You can have PHP convert the case of your strings with: strtes/php/01/olower(), which makes it entirely lowercase; strtoupper(), which capitalizes the uppercase. ucfirst(), which capitalizes the first caharactors and, ucword(), which capitalizes the first charaacters of every word.
If you assing variable (say $book), the new value. If you are merely concatenating one value to nother, you use the concatenation assignment operator(.=).
$title = $title . $subtitle; $title .= $subtitle;
The initial example in this sectioncould be rewritten using either
$name = "$first_name $last_name"; or $name = $first_name; $name .= ""; $name .= $last_name;
The connection operators can be used wothin your functions, like so:
print $first_name . ' ' . $last_name;
Ex: strings_function.phps | strings_function.php
Page: First - 1 2 3 4 5 6 7 8 9 10 - Last
|