mardi 12 juin 2018

PHP: Split a string by comma(,) but ignoring anything inside square brackets?

How do I split a string by , but skip the one that's inside an array

String - "'==', ['abc', 'xyz'], 1"

When I do explode(',', $expression) it's giving me 4 item in array

array:4 [
   0 => "'=='"
   1 => "['abc'"
   2 => "'xyz']"
   3 => 1
]

But I want my output to be -

array:3 [
   0 => "'=='"
   1 => "['abc', 'xyz']"
   2 => 1
]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire