Reputation: 383
I am very new in PHP and I was checking whether all my controlers are in so how can I echo this? what I tried resulting nothing
$controllers = array_intersect($json_api->get_controllers(), $active_controllers );
$return = array(
'json_api_version' => $version,
'controllers' => array_values($controllers)
);
echo $return['controllers']['controllers'];
Upvotes: 0
Views: 353
Reputation: 387
If you want to print the values of an array with a
understandable format you should use print_r()
instead of echo
like so:
print_r($return['controllers']);
You can also use var_dump()
to get some extra information about the fields, like the type and lenght.
If what you need is to asign a certain index of the array to a value just do something like this:
$variable = $return['controllers'][indexOfField]; // indexOfField=2 for city field
echo $variable;
For further information about print_r()
check the official manual.
Upvotes: 1
Reputation: 7023
use print_r
function:
print_r($return['controllers']);
when you want read city you do:
$arr_controllers = $return['controllers'];
$key_2 = $arr_controllers[2];
where 2 is the key
Upvotes: 1