Digital Jedi
Well-known member
Does xF just not like RecursiveIteratorIterator? This code worked on a non xF test page. Is it a nesting issue?
PHP:
<?php
namespace ycard;
class ycard{
public static function getYcard(\XF\Pub\Controller\AbstractController $controller, \XF\Mvc\Reply\AbstractReply &$reply) {
$url = 'https://db.ygoprodeck.com/api/v7/cardinfo.php';
$parameter = $_SERVER['QUERY_STRING'];
$request_url = $url . '?' . $parameter;
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
//echo $response . PHP_EOL;
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($response, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key => $val) {
if(!is_array($val)) {
if($key == "set_code") {
print "<br/>";
}
print $key." : ".$val . "<br/>";
}
}
}
?>