[Solved] Removing unwanted key/value pair in php array? [closed]


check this, use is is_numeric to check number or string.

$data = array("0"=>"1","id"=>"1","1"=>"mani","name"=>"mani","2"=>"ssss","lname"=>"ssss");

foreach ($data as $key => $val)
{
    if(!is_numeric($key))
    {
        $new_array[$key] = $val;
    }
}  

print_r($new_array);

OUTPUT :

Array
(
    [id] => 1
    [name] => mani
    [lname] => ssss
)

DEMO

1

solved Removing unwanted key/value pair in php array? [closed]