Welcome Guest, Not a member yet? Register   Sign In
Issue using RecursiveIteratorIterator in a controller
#2

It's a namespace issue. Within your controller, you're in the namespace App\Controllers. The RecursiveIteratorIterator is NOT in that namespace, so you must prefix it with a backslash, or add it as a use statement at the top of the file. That allows PHP to know to look for it in the root namespace, not in the current namespace (App\Controllers).

PHP Code:
$newDataIterator = new \RecursiveIteratorIterator
   new \
RecursiveArrayIterator(json_decode($dataArrayTRUE)),
   \
RecursiveIteratorIterator::SELF_FIRST
); 

or

PHP Code:
<?php namespace App\Controllers;

use 
RecursiveIteratorIterator;
use 
RecursiveArrayIterator;

  public function 
index() {
    
$newDataIterator = new RecursiveIteratorIterator
        new 
RecursiveArrayIterator(json_decode($dataArrayTRUE)),
        
RecursiveIteratorIterator::SELF_FIRST
    
); 
  }

Reply


Messages In This Thread
RE: Issue using RecursiveIteratorIterator in a controller - by kilishan - 05-25-2020, 11:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB