Home  >  Article  >  Backend Development  >  How to delete array elements in PHP?

How to delete array elements in PHP?

WBOY
WBOYOriginal
2016-12-01 00:57:05806browse

Just remove both keys and values..

<code>foreach($arr as $k => $v )
{
    if($v>10)
        删除arr[$k]

}

</code>

Reply content:

Just remove both keys and values..

<code>foreach($arr as $k => $v )
{
    if($v>10)
        删除arr[$k]

}

</code>

<code>$arr = [
    'test' => 'test',
    'test1' => 'test1'
];

unset($arr['test'])

print_r($arr);

#####输出
[
    'test1' => 'test1'
]</code>
Statement:
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