I have read a number of the answers on this but I am not getting something. I have an object that retrieves data from a file and puts into an array format and I am trying to get the data into a variable in the calling file so that I can work with the data.
calling.php
$x = new obj();
$x -> method_y();
objectfile.php
public function method_y(){
..... code does stuff .....
print_r($array);
}
array(
[0] => array
(
[key1] => value1
[key2] => value2
[key3] => value3
)
[1] => array
(
[key1] => value1
[key2] => value2
[key3] => value3
)
)
Is is better to use an echo, return, or print from the method and should I use the json_encode to return it. How do I get the returned data into out of the object into something I can work with. For instance using the json_encode in the method I get back json but the json_decode wants a string.
Again I have read a number of answers on this but I am not getting it.
Thanks in advance.