Changes

Working with Strings and Text in PHP

798 bytes added, 13:18, 4 June 2007
Converting to and from ASCII Values
* '''ucwords()''' - Converts the first letter of every word to uppercase
=== Converting to and from ASCII Values ===
PHP provides the ability to work with ASCII (American Standard Code for Infomration Interchange) values. ASCII maps numerical character codes to standard, human readable characters. There are 127 ASCII characters representing the letters of the alphabext (including upper and lower case), numbers and various punctuation marks. There is also an extended character set which contains 255 characters.
The character for ASCII code for is A
</pre>
 
== Printing Formatting Strings in PHP ==
 
Those familar with other programming langusges such as C and C++ will probably be familiar with the concept of formatting strings and the ''printf()'' function. The printf function allows strings to constructed which contain variables and provides a number of formatting options for those variables.
 
Essentially printf allows you to specify a string and define how particular variables are to be embedded in that string. ''fprintf()'' takes two or more arguments and takes the the following form:
 
fprintf ( "String containing embedded formatting rules", variable1, variable2, ..., +/-, 'padding char', +/-, width, precision, type );
 
PHP will scan the string for the formatting specifiers or rules and substitute that rule for the corresponding variable.