Home > Backend Development > PHP Tutorial > How to print out an array within an array?

How to print out an array within an array?

WBOY
Release: 2016-08-04 09:20:43
Original
1716 people have browsed it

<code>    <?php
  $ar=array(array(5,'x'),'q',5);
  echo implode($ar);
    ?></code>
Copy after login
Copy after login

Like the above code, how to print the contents of array(5,'x')?

Reply content:

<code>    <?php
  $ar=array(array(5,'x'),'q',5);
  echo implode($ar);
    ?></code>
Copy after login
Copy after login

Like the above code, how to print the contents of array(5,'x')?

foreach($ar as $v){

<code>    if(is_array($v)){ //如果值是一个数组
        foreach($v as $vv){
            echo $vv."<br>";
        }
    }else{ //不是数组直接打印
        echo $v."<br>";
    }
}</code>
Copy after login

!!!
var_dump Don’t you know?

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template