Search code examples
phpsplitpreg-split

PHP Split Problem


I am trying to use (and I've tried both) preg_split() and split() and neither of these have worked for me. Here are the attempts and outputs.

preg_split("^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it.
preg_split("\^", "ItemOne^ItemTwo^Item.Three^");
//output - null or false when attempting to implode() it. Attempted to escape the needle.
//SAME THING WITH split().

Thanks for your help... Christian Stewart


Solution

  • split is deprecated. You should use explode

    $arr = explode('^', "ItemOne^ItemTwo^Item.Three^");