How to delete the key of a one-dimensional array without using two foreach loops.

WBOY
Release: 2016-07-06 13:52:04
Original
1050 people have browsed it

1. I want to turn a two-dimensional array into one dimension and delete the arr value of one-dimensional KEY. Is there a function?
2. Array code:

<code> stdClass Object
(
    [arr] => stdClass Object
        (
            [0] => stdClass Object
                (
                    [id] => 14
                    [cid] => 221
                    [title] => 深圳市轨道交通网络运营控制中心室内精装、玻璃幕墙工程
                    [source] => 
                    [count] => 0
                    [img] => http://upload.55.cn/source/44/201606/50457731d4be5e5c1.jpg
                    [info] => 
                    [fee] => 0
                    [url] => /product/detail/14.html
                    [cate_name] => 装修工程
                )

            [1] => stdClass Object
                (
                    [id] => 12
                    [cid] => 220
                    [title] => 南充嘉陵江1000T级泊位都京码头
                    [source] => 
                    [count] => 0
                    [img] => http://upload.55.cn/source/44/201606/55557731d15a3aa42.jpg
                    [info] => 
                    [fee] => 0
                    [url] => /product/detail/12.html
                    [cate_name] => 水利电力工程
                )
</code>
Copy after login
Copy after login

How to delete arr? Otherwise, it would be inelegant to use two foreach loops. .

Reply content:

1. I want to turn a two-dimensional array into one dimension and delete the arr value of one-dimensional KEY. Is there a function?
2. Array code:

<code> stdClass Object
(
    [arr] => stdClass Object
        (
            [0] => stdClass Object
                (
                    [id] => 14
                    [cid] => 221
                    [title] => 深圳市轨道交通网络运营控制中心室内精装、玻璃幕墙工程
                    [source] => 
                    [count] => 0
                    [img] => http://upload.55.cn/source/44/201606/50457731d4be5e5c1.jpg
                    [info] => 
                    [fee] => 0
                    [url] => /product/detail/14.html
                    [cate_name] => 装修工程
                )

            [1] => stdClass Object
                (
                    [id] => 12
                    [cid] => 220
                    [title] => 南充嘉陵江1000T级泊位都京码头
                    [source] => 
                    [count] => 0
                    [img] => http://upload.55.cn/source/44/201606/55557731d15a3aa42.jpg
                    [info] => 
                    [fee] => 0
                    [url] => /product/detail/12.html
                    [cate_name] => 水利电力工程
                )
</code>
Copy after login
Copy after login

How to delete arr? Otherwise, it would be inelegant to use two foreach loops. .

<code class="php">$resultArr = $targetArr['arr'];</code>
Copy after login

Did I understand it wrong?

is the object that should be $result->arr

Convert object to array
$a = $result['arr'];

Related labels:
php
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