PHP: check if object/array is a reference

后端 未结 5 2028

Sorry to ask, its late and I can\'t figure a way to do it... anyone can help?

$users = array(
    array(
        \"name\" => \"John\",
        \"age\"   =         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 16:03

    something recursive maybe.

    function removeReferences($inbound)
    {
        foreach($inbound as $key => $context)
        {
            if(is_array($context))
            {
                $inbound[$key] = removeReferences($context)
            }elseif(is_object($context) && is_reference($context))
            {
                unset($inbound[$key]); //Remove the entity from the array.
            }
        }
        return $inbound;
    }
    

提交回复
热议问题