Ciao a tutti.
ho un file .json cosi costituito:
ora stò provando con queste istruzioni
però non sò come accedere alle informazioni racchiuse dentro al tag "stage".
Per "accedere" intendo in modo separato.
dovrei ottenere:
base
altezza
materiale
poi per decoration
tipo -----> margin top, margine left
poi se tipo è Image , allora --------> nome del file ,margin top, margine left
infine se Type è Text --------> il testo,margin top, margine left,fontFamily,fontSize
qualcuno mi può aiutare ?
grazie a tutti in anticipo
ho un file .json cosi costituito:
JSON:
[
{
"firstname": "test_nome",
"lastname": "test_cognome",
"pdf_link": "http:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/pdf\/test_nome_test_cognome_5eef632ab3e3a.pdf",
"stage": "{\"size\":{\"width\":\"800\",\"height\":\"500\"},\"materiale\":\"rosa\",\"decoration\":{\"type\":\"staffe\",\"count\":4,\"margin\":{\"top\":\"25\",\"left\":\"22\"}},\"items\":[{\"type\":\"Image\",\"path\":\"path1\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path1\/img1.jpeg\",\"margin\":{\"top\":403,\"left\":348}},{\"type\":\"Image\",\"path\":\"path2\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path2\/img12.jpeg\",\"margin\":{\"top\":404,\"left\":591}},{\"type\":\"Image\",\"path\":\"path4\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path4\/img32.jpeg\",\"margin\":{\"top\":346,\"left\":128}},{\"type\":\"Image\",\"path\":\"path7\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path7\/img1.jpg\",\"margin\":{\"top\":259,\"left\":659.5}},{\"type\":\"Image\",\"path\":\"path7\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path7\/img2.png\",\"margin\":{\"top\":262,\"left\":411.5}},{\"type\":\"Image\",\"path\":\"path8\",\"name\":\"https:\/\/www.miosito.it\/stage-2018-cx\/marmo3\/images\/path8\/img1.jpeg\",\"margin\":{\"top\":208,\"left\":195}},{\"type\":\"Text\",\"text\":\"prova test 2\",\"margin\":{\"top\":84.99999999999997,\"left\":540.9999999999995},\"fontFamily\":\"Arial Narrow Bold\",\"fontSize\":\"25\"},{\"type\":\"Text\",\"text\":\"prova test 1\",\"margin\":{\"top\":64,\"left\":224.99999999999974},\"fontFamily\":\"sans-serif\",\"fontSize\":\"22\"}]}"
}
]
PHP:
$string=file_get_contents('data.json', 'r');
$json_o=json_decode($string,true);
foreach($json_o as $p)
{
echo 'Nome: '.$p[firstname]."<br>";
echo 'Cognome: '.$p[lastname]."<br>";
echo 'PDF: '.$p[pdf_link]."<br>";
}
Per "accedere" intendo in modo separato.
dovrei ottenere:
base
altezza
materiale
poi per decoration
tipo -----> margin top, margine left
poi se tipo è Image , allora --------> nome del file ,margin top, margine left
infine se Type è Text --------> il testo,margin top, margine left,fontFamily,fontSize
qualcuno mi può aiutare ?
grazie a tutti in anticipo