给一个多维数据每个下标掺入新的元素。

jackxiang 2008-8-6 14:21 | |
<?php
for($i=1;$i<=5;$i++)
{
  $array_test_all = array("0"=>"test_array","1"=>"test_all");
  $arr_test[] = $array_test_all;
}
print_r($arr_test);
echo "________________________________________________________\n";

foreach($arr_test as $key=> $values)
{

  $arr_test[$key]['ts'][]="111";
}
print_r($arr_test);

?>

Array
(
    [0] => Array
        (
            [0] => test_array
            [1] => test_all
        )

    [1] => Array
        (
            [0] => test_array
            [1] => test_all
        )

    [2] => Array
        (
            [0] => test_array
            [1] => test_all
        )

    [3] => Array
        (
            [0] => test_array
            [1] => test_all
        )

    [4] => Array
        (
            [0] => test_array
            [1] => test_all
        )

)
________________________________________________________
Array
(
    [0] => Array
        (
            [0] => test_array
            [1] => test_all
            [ts] => Array
                (
                    [0] => 111
                )

        )

    [1] => Array
        (
            [0] => test_array
            [1] => test_all
            [ts] => Array
                (
                    [0] => 111
                )

        )

    [2] => Array
        (
            [0] => test_array
            [1] => test_all
            [ts] => Array
                (
                    [0] => 111
                )

        )

    [3] => Array
        (
            [0] => test_array
            [1] => test_all
            [ts] => Array
                (
                    [0] => 111
                )

        )

    [4] => Array
        (
            [0] => test_array
            [1] => test_all
            [ts] => Array
                (
                    [0] => 111
                )

        )

)

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1185/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]