1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<?php $str = '[{"x":"12345","y":"john"},{"x":"12345","y":"stars"}]'; function getCSV($x) { $arr = json_decode($x); $y = array(); foreach($arr as $obj){ $y[] = $obj->y; } echo implode(',', $y); } getCSV($str);
1
john,stars