|
Post by riyazulhuq on Dec 28, 2011 2:33:46 GMT -8
To satisfy our requirement we have used php explode function.
The explode() is breaking a string into an array, and returns an array of strings.
It has three arguments which are separator, string and limit.
Where first and second arguments are mandatory and third is optional.
First argument is separator, which describes where to break the string.
Second argument is string to break.
And the third argument is limit, which describes the maximum number of elements an array will contain.
Follow the under given example, which makes an array after breaking a string.
$string = "Hello World! This will make an array from string."; echo "<pre>"; print_r(explode(" ", $string)); print_r(explode(" ", $string, 2)); print_r(explode(" ", $string, -2)); print_r(explode(" ", $string, 0)); echo "</pre>";
|
|