求助,这种多维数组如何输出呢?

www130139 2015-06-05 11:27:48

Array
(
[0] => Array
(
[url] => http://127.0.0.1/show.php?id=6638
)

[1] => Array
(
[url] => http://127.0.0.1/show.php?id=6637
)

[2] => Array
(
[url] => http://127.0.0.1/show.php?id=6636
)

[3] => Array
(
[url] => http://127.0.0.1/show.php?id=6635
)

[4] => Array
(
[url] => http://127.0.0.1/show.php?id=6634
)

[5] => Array
(
[url] => http://127.0.0.1/show.php?id=6633
)

[6] => Array
(
[url] => http://127.0.0.1/show.php?id=6632
)

[7] => Array
(
[url] => http://127.0.0.1/show.php?id=6631
)

[8] => Array
(
[url] => http://127.0.0.1/show.php?id=6630
)

[9] => Array
(
[url] => http://127.0.0.1/show.php?id=6629
)

[10] => Array
(
[url] => http://127.0.0.1/show.php?id=6628
)

[11] => Array
(
[url] => http://127.0.0.1/show.php?id=6627
)

[12] => Array
(
[url] => http://127.0.0.1/show.php?id=6626
)

[13] => Array
(
[url] => http://127.0.0.1/show.php?id=6625
)

[14] => Array
(
[url] => http://127.0.0.1/show.php?id=6624
)

[15] => Array
(
[url] => http://127.0.0.1/show.php?id=6623
)

[16] => Array
(
[url] => http://127.0.0.1/show.php?id=6622
)

[17] => Array
(
[url] => http://127.0.0.1/show.php?id=6621
)

[18] => Array
(
[url] => http://127.0.0.1/show.php?id=6620
)

)

数组打印出来是这种格式,我想最后输出是这样的格式,怎么做呢?请大神赐教


http://127.0.0.1/show.php?id=6638
http://127.0.0.1/show.php?id=6637
http://127.0.0.1/show.php?id=6636
http://127.0.0.1/show.php?id=6635
http://127.0.0.1/show.php?id=6634
http://127.0.0.1/show.php?id=6633
http://127.0.0.1/show.php?id=6632
http://127.0.0.1/show.php?id=6631
http://127.0.0.1/show.php?id=6630
http://127.0.0.1/show.php?id=6629
http://127.0.0.1/show.php?id=6628
http://127.0.0.1/show.php?id=6627
http://127.0.0.1/show.php?id=6626
http://127.0.0.1/show.php?id=6625
http://127.0.0.1/show.php?id=6624
http://127.0.0.1/show.php?id=6623
http://127.0.0.1/show.php?id=6622
http://127.0.0.1/show.php?id=6621
http://127.0.0.1/show.php?id=6620
...全文
118 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
傲雪星枫 2015-06-06
  • 打赏
  • 举报
回复
引用 楼主 www130139 的回复:

Array
(
    [0] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6638
        )

    [1] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6637
        )

    [2] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6636
        )

    [3] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6635
        )

    [4] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6634
        )

    [5] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6633
        )

    [6] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6632
        )

    [7] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6631
        )

    [8] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6630
        )

    [9] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6629
        )

    [10] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6628
        )

    [11] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6627
        )

    [12] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6626
        )

    [13] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6625
        )

    [14] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6624
        )

    [15] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6623
        )

    [16] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6622
        )

    [17] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6621
        )

    [18] => Array
        (
            [url] => http://127.0.0.1/show.php?id=6620
        )

)
数组打印出来是这种格式,我想最后输出是这样的格式,怎么做呢?请大神赐教


http://127.0.0.1/show.php?id=6638
http://127.0.0.1/show.php?id=6637
http://127.0.0.1/show.php?id=6636
http://127.0.0.1/show.php?id=6635
http://127.0.0.1/show.php?id=6634
http://127.0.0.1/show.php?id=6633
http://127.0.0.1/show.php?id=6632
http://127.0.0.1/show.php?id=6631
http://127.0.0.1/show.php?id=6630
http://127.0.0.1/show.php?id=6629
http://127.0.0.1/show.php?id=6628
http://127.0.0.1/show.php?id=6627
http://127.0.0.1/show.php?id=6626
http://127.0.0.1/show.php?id=6625
http://127.0.0.1/show.php?id=6624
http://127.0.0.1/show.php?id=6623
http://127.0.0.1/show.php?id=6622
http://127.0.0.1/show.php?id=6621
http://127.0.0.1/show.php?id=6620
这样就可以了。

$arr = array(
    array('url'=>'http://127.0.0.1/show.php?id=6638'),
    array('url'=>'http://127.0.0.1/show.php?id=6637'),
    array('url'=>'http://127.0.0.1/show.php?id=6636'),
    array('url'=>'http://127.0.0.1/show.php?id=6635'),
    array('url'=>'http://127.0.0.1/show.php?id=6634'),
    array('url'=>'http://127.0.0.1/show.php?id=6633'),
    array('url'=>'http://127.0.0.1/show.php?id=6632'),
    array('url'=>'http://127.0.0.1/show.php?id=6631'),
    array('url'=>'http://127.0.0.1/show.php?id=6630'),
    array('url'=>'http://127.0.0.1/show.php?id=6629'),
    array('url'=>'http://127.0.0.1/show.php?id=6628'),
    array('url'=>'http://127.0.0.1/show.php?id=6627'),
    array('url'=>'http://127.0.0.1/show.php?id=6626'),
    array('url'=>'http://127.0.0.1/show.php?id=6625'),
    array('url'=>'http://127.0.0.1/show.php?id=6624'),
    array('url'=>'http://127.0.0.1/show.php?id=6623'),
    array('url'=>'http://127.0.0.1/show.php?id=6622'),
    array('url'=>'http://127.0.0.1/show.php?id=6621'),
    array('url'=>'http://127.0.0.1/show.php?id=6620')
);

foreach($arr as $k=>$v){
    echo $v['url'].'<br>';
}
luckyAndzpp 2015-06-06
  • 打赏
  • 举报
回复
<?php $sz=array( array( "url" => "http://127.0.0.1/show.php?id=6638"), array( "url" => "http://127.0.0.1/show.php?id=6637"), array( "url" => "http://127.0.0.1/show.php?id=6636"), array( "url" => "http://127.0.0.1/show.php?id=6635"), array( "url" => "http://127.0.0.1/show.php?id=6634"), array( "url" => "http://127.0.0.1/show.php?id=6633"), array( "url" => "http://127.0.0.1/show.php?id=6632"), array( "url" => "http://127.0.0.1/show.php?id=6631"), array( "url" => "http://127.0.0.1/show.php?id=6630"), array( "url" => "http://127.0.0.1/show.php?id=6629"), array( "url" => "http://127.0.0.1/show.php?id=6628"), array( "url" => "http://127.0.0.1/show.php?id=6627"), array( "url" => "http://127.0.0.1/show.php?id=6626"), array( "url" => "http://127.0.0.1/show.php?id=6625"), array( "url" => "http://127.0.0.1/show.php?id=6624"), array( "url" => "http://127.0.0.1/show.php?id=6623"), array( "url" => "http://127.0.0.1/show.php?id=6622"), array( "url" => "http://127.0.0.1/show.php?id=6621"), array( "url" => "http://127.0.0.1/show.php?id=6620"), ); for($ai=0;$ai<count($sz);$ai++) { echo $sz[$ai][url]."<br />"; }; ?>
xuzuning 2015-06-06
  • 打赏
  • 举报
回复
if(! function_exists('array_column')) :
  function array_column($input, $column_key, $index_key=null) {
    $res = array_map(function($tmp) use ($column_key) { return $tmp[$column_key]; }, $input);
    if(! empty($index_key)) $res =  array_combine(array_column($input, $index_key), $res);
    return $res;
  } 
endif;

$records = array(
    array(
        'id' => 2135,
        'first_name' => 'John',
        'last_name' => 'Doe',
    ),
    array(
        'id' => 3245,
        'first_name' => 'Sally',
        'last_name' => 'Smith',
    ),
    array(
        'id' => 5342,
        'first_name' => 'Jane',
        'last_name' => 'Jones',
    ),
    array(
        'id' => 5623,
        'first_name' => 'Peter',
        'last_name' => 'Doe',
    )
);
 
$first_names = array_column($records, 'id');//'first_name');
print_r($first_names);
$last_names = array_column($records, 'last_name', 'id');
print_r($last_names);
Array
(
    [0] => 2135
    [1] => 3245
    [2] => 5342
    [3] => 5623
)
Array
(
    [2135] => Doe
    [3245] => Smith
    [5342] => Jones
    [5623] => Doe
)

水亦未殇 2015-06-05
  • 打赏
  • 举报
回复

var_dump(array_column($data,'url'));
去看下array_column函数就知道了

21,873

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧