getting values from a php array
I want to get values from an array, For example this is array:
$tags_array = $_REQUEST['item'];
With print_r
, I get following:
Array
(
[tags] => Array
(
[0] => tag1
[1] => tag2
)
)
I want to get values of array with for each loop.
foreach ($tags_array as $tag) {
echo $tag;
}
It prints nothing. T开发者_StackOverflow社区hanks for help.
You have an array in an array. Try this
foreach ($tags_array['tags'] as $tag) {
echo $tag;
}
You have two arrays, one inside another:
foreach ($tags_array as $tag_array) {
foreach ($tag_array as $tag)
echo $tag;
}
精彩评论