[ create a new paste ] login | about

Link: http://codepad.org/HzttdmjW    [ raw code | output | fork ]

PHP, pasted on Apr 20:
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);


Output:
1
john,stars


Create a new paste based on this one


Comments: