问基础有关问题

WBOY
Release: 2016-06-13 11:15:13
Original
851 people have browsed it

问基础问题

    public function match_stuff($content){<br />       $artlist = pq('.stepcont');<br />       foreach($artlist as $li){<br />        $stuff[] -> approved = pq($li)->find('p')->text();<br />        if($stuff){<br />        $stuff[] -> kkli = pq($li)->find('a img')->attr('src');<br />}}<br />    return $stuff;<br />    }
Copy after login

现在转json后是这个效果
[<br />    {<br />        "approved": "wwwwwww"<br />    },<br />    {<br />        "kkli": "33333333333333"<br />    },<br />    {<br />        "approved": "444444444444444"<br />    },<br />    {<br />        "kkli": "55555555555"<br />    },<br />    {<br />        "approved": "6666666666"<br />    },<br />    {<br />        "kkli": "7777777777777777"<br />    },<br />    {<br />        "approved": "88888888888"<br />    },<br />    {<br />        "kkli": "999999999999"<br />    },<br />    {<br />        "approved": "0000000000000"<br />    },<br />    {<br />        "kkli": "111111111111111"<br />    },<br />    <br />]
Copy after login


我想要这个效果,上面应该怎么改?
[<br />    {<br />        "approved": "wwwwwww","kkli": "33333333333333"<br />    },<br /><br />    {<br />        "approved": "444444444444444","kkli": "55555555555"<br />    },<br /><br />    {<br />        "approved": "6666666666","kkli": "7777777777777777"<br />    },<br />    {<br />        "approved": "88888888888","kkli": "999999999999"<br />    },<br />    {<br />        "approved": "0000000000000","kkli": "111111111111111"<br />    },<br />    <br />]
Copy after login

直接贴上代码来谢谢


------解决方案--------------------
$artlist = pq('.stepcont');<br />foreach($artlist as $li){<br />  $stuff[] = array(<br />    'approved' => pq($li)->find('p')->text(),<br />    'kkli' => pq($li)->find('a img')->attr('src')<br />  );<br />}<br />return $stuff;
Copy after login

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