I have a string like this it is array pattern :
["foo","bar","bra bra","xxx123"]
How can i get the foo,bar,bra bra,xxx123
Pattern is ["","",""]
Since php 5.4 that is a shorthanded way of doing an array.
See: http://docs.php.net/manual/en/language.types.array.php
Specific quote:
As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
Therefore the basic way is like any other array:
$arr = ["foo","bar"];
foreach($arr AS $arg){
echo $arg; //you can add your logic here for comma seperating or beautifying
}
I suspect, that a regex might be the wrong tool - try explode!
$string='["foo","bar","bra bra","xxx123"]';
//Remove start/end
if (substr($string,0,2)!='["') die('Malformed start!');
if (substr($string,-2)!='"]') die('Malformed end!');
$string=substr($string, 2, -2);
//Now explode
$array=explode('","', $string);
print_r($array);
json_decode()is a risk