开发者

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;
       } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜