I have an array that for some reason keeps kicking back an error "Illegal String Offset" I have tried several ways to loop through it but none seem to work.
$fields = Array (
[cookies] => Array (
[timeout] => 0
[votes_per_cookie] => 1
[enabled] => on
)
[ip] => Array (
[timeout] => 0
[filter] =>
)
[direct] => Array ( )
[membership] => Array (
[type] => Array ( )
[once] => Array ( )
)
[captcha] => Array ( )
[quota] => Array (
[votes] => 1000
)
[date] => Array (
[start] => 1553846400
[end] => 1554767940
[enabled] => on
)
[selection] => Array (
[minimum] => 1
[maximum] => 1
)
[unique_id] => 1547834405
[results] => Array (
[require_vote] => Array (
[enabled] => on
)
)
);
I am trying to get the value of end in the date array. I have tried this:
foreach($fields as $field) {
echo $field['end'];
}
this outputs the data but also the illegal offset error.
I have tried this:
foreach($fields as $key => $value) {
echo $value['end'];
}
This also outputs the same reponse.
if I echo key using the above loop, it returns the appropriate keys (cookies, ip, direct, membership, etc)
I have also tried:
foreach($fields['date'] as $field) {
$field['end'];
}
This is just an error.
And finally
foreach($fields as $field) {
$field['date']['end'];
}
just an error.