| Charles C. Spencer |
| CIS 52N Spring 2008 |
| Practice Chapter 5 |
| Constructing Text Strings: |
|---|
|
"Dr. Livingstone, I presume?" |
| strlen: |
|---|
Returns the number of characters in a string. The book title contains 23 characters. |
| strpos: |
|---|
Performs a case-sensitive search and returns the position of the last occurrence of one string in another string. $Email = "president@whitehouse.gov"; searching for: '@' and 'p', or if '@' exits... 90 The email address contains an @ character. |
| strchr: |
|---|
Performs a case-sensitive search for specified characters in a string and returns a substring from the last occurrence of the specified characters to the end of the string. The domain identifier of the email address is .gov. |
| substr: |
|---|
Returns a portion of a string. The name portion of the email addres is 'president'. The domain name portion of the email address is 'whitehouse'. |
| str_replace(), str_ireplace(), and substr_replace: |
|---|
str_ireplace: performs a case-insensitive replacement of all occurances of specified characters in a string. 'str_replace' : replace with new email address. vice.president@whitehouse.gov
George Herbert Walker h was the 41st president of the United States. George Walker Bush is the 43rd president of the United States. |
| strtok: |
|---|
breaks a string into smaller strings, called 'tokens'. Geroge W. BushWilliam Clinton George H.W. Bush Ronald Regan Jimmy Carter |
| explode/implode: |
|---|
The 'explode()' function splits a string into an indexed array at a specified separator. George W. BushWilliam Clinton George H.W. Bush Ronald Reagan Jimmy Carter The 'implode()' function combines an array's elements into a single string, separated by specified characters. George W. Bush, William Clinton, George H.W. Bush, Ronald Reagan, Jimmy Carter |
| strcasecmp() and strcmp(): |
|---|
strcasecmp() performs a case-insensitive comparison of two strings. strcasecmp("Don", "don"); // returns 0; ;strncmp() performs a case-sensitive comparison of strings. strcmp("Dan", "Don"); // returns -1 strncmp: Both cities begin with 'San'. |
| similar_text() and levenshtein(): |
|---|
similar_text and levenshtein() functions are used to determine the similarity between two strings. The names "Don" and "Dan" have 2 characters in common. You must change 1 character(s) to make the names "Don" and "Dan" the same. |
| soundex() and metaphone(): |
|---|
soundex() and metaphone() functions determine whether two strings are pronounced similarly. $FirstName="Gosselin"; $SecondName="Gauselin"; metaphone(): (returns a code representing an English word's approximate sound) The names are pronounced the same. soundex(): returns a value representing a name's phonetic equivalent. The names are pronounced the same. |
| isset(), empty(), and is_numeric: |
|---|
isset() function determines whether a variable has been declared and initialized. |
Specifying Types: value = 123.123 Binary integer: 1111011 |