Reputation: 435
I have this snippet :
<?php
$list = $modx->runSnippet('getResources', array(
'parents'=>'16',
'depth'=>'1',
'includeContent'=>'1',
'limit'=>'1'
));
$output = explode(',', $list);
//print_r($list);
foreach($output as $i) {
//echo $i;
foreach($i as $key => $value) {
echo $key.' : '.$value.'<br />';
}
}
With print_r I can see the array ;-)
But using the foreach loop... nothing print !
Thanks for your help...
Upvotes: 1
Views: 1536
Reputation: 3146
The problem might be that you are calling 'explode' on an array when it should be taking a string.
Not sure exactly what your $list array looks like, but perhaps try this instead:
foreach ($list as $i) {
foreach ($i as $key => $value) {
echo $key.' : '.$value.'<br />';
}
}
EDIT Have tested this and $list is not an array but a pre-formatted string meant for debugging:
<pre>Array
(
[tpl] =>
[tplOdd] =>
[tplFirst] =>
...
</pre>
I'm not sure exactly what you want to achieve, but it's usually better to use the tpl parameter to format results using a Chunk.
getResources is designed for listing Resources for front end display and is not generally used to retrieve raw data.
Upvotes: 2