TeAmEr
TeAmEr

Reputation: 4773

How to replace split() with preg_split() in my PHP code?

Could you please help me with converting $x_ary = split('&x=', $url); to the preg_split() equivalent?

Upvotes: 1

Views: 1155

Answers (1)

mario
mario

Reputation: 145482

In most cases you just need to add delimiters:

 preg_split('/&x=/',$url)

/ are fine if you do not need them as part of the pattern. And none of the other symbols are meta characters, so don't need escaping.

Take note that in your case you could just use explode instead, since you don't need a regex.

Upvotes: 3

Related Questions