Home  >  Q&A  >  body text

Scope of php array?

The poster has done too much research, maybe the keyword description is incorrect and no corresponding explanation was found.

I will post the picture first:

捕获2.PNG

That’s about it, why can print_r output, but there is no output in echo? Good people have a safe life, maybe I don’t understand the scope well...

adolphe_ssadolphe_ss2551 days ago1428

reply all(3)I'll reply

  • 电动小老虎

    电动小老虎2017-11-17 00:04:50

    each can traverse the array and then assign the array to a variable. Then the variable becomes an array. list can turn the elements of the default index array into variables such as $arr= range(1,3) list($a,$b,$c)=$arr echo $a,$b,$c is 1,2,3 That's probably what it means.

    reply
    0
  • 电动小老虎

    Each traversing the array will return 4 elements 0, 1, key, value; And the array pointer will automatically move downwards

    电动小老虎 · 2017-11-17 00:08:53
  • adolphe_ss

    adolphe_ss2017-11-16 21:12:32

    <hr size="5px" width="90%"/>
    <?php
    static $arr = array("张三","李四");
    $name = each($arr);
    print_r($name);echo '<br />';
    $name = each($arr);
    print_r($name);echo'<br />';
    ?>
    <hr size="3pt" color="green"  width="50%" />
    <?php
    print_r($arr);
    //$arr =array("张三","李四");
    list($key, $value) = each($arr);
    echo "$key=>$value";
    ?>

    Attachment: The code of Figure 2.

    reply
    0
  • Cancelreply