Wednesday, July 29, 2009

split a string.

let's see the zend mock exam question related to splitting a string in php.

Question: Which of the following is the best way to split a string on the "-=-" pattern?

Answer:

1. They all are equally proper methods
2. str_split($string, strpos($string, "-=-"))
3. preg_split("-=-", $string);
4. explode("-=-" $string);
it doesn't have a ','.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide

1 comment:

Anonymous said...

4 is correct, even thou the , is missing. I guess this is just a typo as there are many in the mock test.