Home > Backend Development > PHP Tutorial > 求教下数组输出的问题

求教下数组输出的问题

WBOY
Release: 2016-06-23 14:15:05
Original
877 people have browsed it

本帖最后由 redirggg 于 2013-07-04 11:55:04 编辑

Array(    [IsSuccesfull] => 1    [Results] => Array        (            [SingleResul] => Array                (                    [0] => Array                        (                            [QueryId] => 100093                            [PathId] => 1                            [SourceFolder] => 1111111                        )                    [1] => Array                        (                            [QueryId] => 100093                            [PathId] => 2                            [SourceFolder] => 1111                       )                )        ))
Copy after login


求教这种数组如何输出?


回复讨论(解决方案)

你想怎么输出??

想输出QueryId、PathId、SourceFolder,然后QueryId重复的话只输出第一个,求大神指点。

假设 $t 是你的数组

$ar=array();foreach($t['Results']['SingleResul'] as $v){        if(!isset($ar[$v['QueryId']])){                $ar[$v['QueryId']]=$v;        }}foreach($ar as $v)  echo join(' | ' , $v)."<br>";
Copy after login
Copy after login

非常感谢jordan102大牛!

假设 $t 是你的数组

$ar=array();foreach($t['Results']['SingleResul'] as $v){        if(!isset($ar[$v['QueryId']])){                $ar[$v['QueryId']]=$v;        }}foreach($ar as $v)  echo join(' | ' , $v)."<br>";
Copy after login
Copy after login


在请教下大牛,比如数组如下:
                    [1] => Array
                        (
                            [QueryId] => 100093
                            [PathId] => 2
                            [SourceFolder] => 1111
                       )
如果某元素中PathId = 2,就删除该数组元素。求教。
Related labels:
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