2015-09-12 50 views

回答

1

在這裏,你需要做的:

$json = '[ 
    {"name": "abaneel", "age" : 23}, 
    {"name": "john", "age" : 32}, 
    {"name": "Dev", "age" : 22} 
]'; 
$implode = array(); 
$multiple = json_decode($json, true); 
foreach($multiple as $single) 
    $implode[] = implode(', ', $single); 

echo implode(', ', $implode); //this will output abaneel, 23, john, 32, Dev, 22 
/* 
    You can see that it will be hard to distinguish that where line(one array is ending); 
*/ 
echo implode(' | ', $implode); //will output abaneel, 23 | john, 32 | Dev, 22 

希望這將有助於

+0

謝謝穆賓哈立德 –

+0

我很高興這對你有用。 – Mubin

+0

如果這項工作,您可以標記爲答案。 – Mubin

0
<?php 
$json ='[ 
    {"name": "abaneel", "age" : 23}, 
    {"name": "john", "age" : 32}, 
    {"name": "Dev", "age" : 22} 
]'; 

$data=json_decode($json,true); 
$your_string=""; 

foreach($data as $key=>$v){ 
    $your_string.=$data[$key]['name'].",".$data[$key]['age'].","; 
} 
$your_string= trim($your_string, ","); 
echo $your_string; 

?> 
相關問題