Source Code:
(back to article)
<?php $array = [new stdClass(), new stdClass(), new stdClass()]; $objectToRemove = new stdClass(); $key = array_search($objectToRemove, $array); if ($key !== false) { unset($array[$key]); echo "Object removed from the array!"; } else { echo "Object not found in the array."; } ?>
Result:
Report an issue