Chapter
Arrays of Strings
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How can you extract substrings from a string in PHP?
"$name = \"Thomas Alan Waits\";\n\n$firstName = substr($name, 0, 6); //\"Thomas\"\n\n$middleName = substr($name, 7, 4); //\"Alan\"\n\n$lastName = substr($name, 12); //\"Waits\"\n\nIn the final example
- How can you define arrays of strings in PHP?
"We often need to deal with collections of strings. In PHP we can define arrays of strings. Indeed, we’ve seen arrays of strings before. When processing command line arguments, PHP defines an array of
- How can you compare strings by their content in PHP?
"When comparing strings in PHP, we can use the usual comparison operators such as ===, <, or <= which will compare the strings lexicographically. However, this is generally discouraged because of type