Converting an Array into a String Just as you can use theexplode()function to divide a delimited string into various array elements, you concatenate array elements to form a single delimited string using theimplode()function. Its prototype follows: string implode(string delimiter, array pieces) This example forms a string out of the elements of an array: <?php This returns the following: -------------------------------------------- Performing Complex String Parsing Thestrpos()function finds the position of the first case-sensitive occurrence ofsubstrin a string. Its prototype follows: int strpos(string str, string substr [, int offset]) The optional input parameteroffsetspecifies the position at which to begin the search. Ifsubstris not instr,strpos()will returnFALSE. The optional parameteroffsetdetermines the position from whichstrpos()will begin searching. The following example determines the timestamp of the first timeindex.htmlis accessed: <?php // Find the numerical position of the end of the line // Calculate the beginning of the timestamp // Retrieve the timestamp echo "The file $substr was first accessed on: $timestamp"; This returns the position in which the fileindex.htmlis first accessed: -------------------------------------------- The functionstripos()operates identically tostrpos(), except that it executes its search case insensitively.
blog comments powered by Disqus |
|
|
|
|
|
|
|