I am getting a dynamic value in the following format, can anyone help me how to get rid of extra chars using preg_replace()?
case1) $string='""14""';
case2) $string='""string1""';
case3) $string='"[\"string1\", \"string2\"]"';
case4) $string='"[\"string1\", \"string21\", \"string3\"]"';
here i want to get rid of only " [ \ ] but not comma ',', so if it is one string i will get only double quotes but if it is more than one i will get in the farm comma separated.
i need following output.
case1) 14
case2) string1
case3) string1,string2
case4) string1,string21,string3
Thanks in advance for your help...
var_dump(json_decode($string));
in case 4, for example... you might be surprized at how easy things can be – Elias Van Ootegem