多次元配列を持っているので、配列から 'img'データを取得したい。配列から画像データを取得する方法
以下は私の結果の配列である、
"{'0':{'id':'area-design'},'1':{'id':'images-1','width':'500px','height':'500px','top':'0px','left':'0px','zIndex':'auto','img':'http:\/\/192.168.1.156\/dutees\/tshirtecommerce\/\/uploaded\/products\/dg-designer-fbfe5ba2144332567936169114610928496.png'}}""{'0':{'id':'area-design'},'1':{'id':'images-1','width':'500px','height':'500px','top':'0px','left':'0px','zIndex':'auto','img':'http:\/\/192.168.1.156\/dutees\/tshirtecommerce\/\/uploaded\/products\/dg-designer-fbfe5ba2144332567936169114610928496.png'}}""{'0':{'id':'area-design'},'1':{'id':'images-1','width':'500px','height':'500px','top':'0px','left':'0px','zIndex':'auto','img':'http:\/\/192.168.1.156\/dutees\/tshirtecommerce\/\/uploaded\/products\/dg-designer-56a3107c144332567919932061810464914.png'}}""{'0':{'id':'area-design'},'1':{'id':'images-1','width':'500px','height':'500px','top':'0px','left':'0px','zIndex':'auto','img':'http:\/\/192.168.1.156\/dutees\/tshirtecommerce\/\/uploaded\/products\/dg-designer-69b4fa3b144332567968295645910544813.png'}}"
以下のコードは、
$file = dirname(DIR_SYSTEM) . '/tshirtecommerce/data/products.json';
if (file_exists($file))
{
$string = file_get_contents($file);
if ($string != false)
{
$e_products = json_decode($string);
if (isset($e_products->products) && count($e_products->products) > 0)
{
foreach($e_products->products as $values)
{
foreach ($values->design->back as $ck => $ch){
echo json_encode($ch);
}
}
}
}
}
をあなたの 'JSON'が有効ではありません。 –
jsonの無効な[http://jsonviewer.stack.hu/]を確認してください –
私はjsonのキーと値が二重引用符で囲まれていると思います – JYoThI