Answers for "unset in object php"

PHP
5

delete property from object php

unset($a->new_property);
Posted by: Guest on March-15-2020
0

php remove object from array by property

$new_array = [];
foreach ($myarray as $key => $value) {
    if ($value->catid == 29) {
        $new_array[] = $value;
        unset($myarray[$key]);        
    }
}
Posted by: Guest on May-20-2021

Browse Popular Code Answers by Language