0

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

1

4 Answers 4

1

split is deprecated. You should use explode

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

Sign up to request clarification or add additional context in comments.

Comments

1

Try

explode("^", "ItemOne^ItemTwo^Item.Three^");

since your search pattern isn't a regex.

Comments

1

Are you sure you're not just looking for explode?

explode('^', 'ItemOne^ItemTwo^Item.Three^');

Comments

0

Since you are using preg_split you are trying to split the string by a given regular expresion. The circumflex (^) is a regular expression metacharacter and therefore not working in your example.

btw: preg_split is an alternative to split and not deprecated.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.