How to find index of object in php array?

前端 未结 10 2222
时光说笑
时光说笑 2021-02-13 18:46

Here is print_r output of my array:

Array
(
[0] => stdClass Object
    (
        [itemId] => 560639000019
        [name] => Item no1
        [code] =>         


        
10条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 19:36

    try this

    foreach($array AS $key=>$object){
       if($object['id'] == 4){
           $key_in_array = $key;
       }
    }
    
    // chop it from the original array
    array_slice($array, $key_in_array, 1);
    

提交回复
热议问题