Vanuit een nested Array probeer ik de resultaten te outputen. Nu loop ik tegen het probleem aan dat wanneer ik mijn variable in een echo "<a href= statement probeer te zetten de waarde uit het variable leeg is. Verder als ik bijvoorbeeld twee keer de variable probeer te tonen door:
echo $label;
echo $label;
Is de waarde van de tweede variable ook leeg. Weet iemand wat dit zou kunnen veroorzaken?
De waarde van $array ziet er zo uit:
echo $label;
echo $label;
Is de waarde van de tweede variable ook leeg. Weet iemand wat dit zou kunnen veroorzaken?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, 'http://localhost:9019/jsonrpc'); //prepare the field values being posted to the service $data = '{"jsonrpc": "2.0", "method": "Files.GetSources", "params" : { "media" : "video" }, "id": 1}'; curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $array = json_decode(curl_exec($ch),true); $xbmcresults = $array['result']['shares']; foreach ($xbmcresults as $var) { //echo print_r($xbmcresults[$row][label]); $label = substr(print_r($var[label]),0,-1); $source = substr(print_r($var[file]),0,-1); echo $label; echo $label; echo "<br />"; echo $source; echo "<br />"; } ?> |
De waarde van $array ziet er zo uit:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| Array ( [id] => 1 [jsonrpc] => 2.0 [result] => Array ( [end] => 3 [shares] => Array ( [0] => Array ( [fanart] => special://masterprofile/Thumbnails/Video/Fanart/76b0f81b.tbn [file] => /home/xbmc/Videos/ [label] => Videos ) [1] => Array ( [fanart] => special://masterprofile/Thumbnails/Video/Fanart/c06da014.tbn [file] => /home/xbmc/TV Shows/ [label] => TV Shows ) [2] => Array ( [fanart] => special://masterprofile/Thumbnails/Video/Fanart/c4909a11.tbn [file] => /data/xbmc/TV Shows/ [label] => TV Shows (2) ) ) [start] => 0 [total] => 3 ) ) 1 |
[ Voor 56% gewijzigd door Erhnam op 29-09-2010 16:19 ]
http://www.xbmcfreak.nl/