Reputation: 261
I ran a var_dump
on my variable that is a list of information, here is the result of the var_dump
array(2) { ["name"]=> string(3) "top" ["value"]=> string(4) "100%" }
array(2) { ["name"]=> string(4) "left" ["value"]=> string(3) "Gus" }
array(2) { ["name"]=> string(4) "text" ["value"]=> string(4) "Hank" }
How do I get the value of the [name]
=> "top"
([value]
here is 100%)so on and so forth?
Here is the PHP
foreach ($field['options'] as $key => $value) {
echo '<div style="color: #fff;">';
echo '<li style="color: #fff;">'.var_dump ($value).'</li>';
echo '</div>';
}
To get "top"
I tried $value['top']
just like $field['options']
gets the options array, how do I break it down to get each speific option?
Upvotes: 0
Views: 2380
Reputation: 54212
You mis-use var_dump($value)
.
Assume $field['options']
is the array you var_dump
at the beginning, you can just use $value['name']
instead of var_dump($value)
.
To find specific value, use something like if($value['name'] === 'top')
in the foreach loop
Sidenote: The function var_dump()
is to print the variable content. To get it inline / into a variable, use var_export($variable, true)
.
Upvotes: 2
Reputation: 13535
Use $value['name']
and $value['value']
to get the respective values.
Upvotes: 1