I have an array that looks like this:
$array = array(
array('name' => 'number1', 'number' => '0612345675'),
array('name' => 'number2', 'number' => '0634345675'),
array('name' => 'number3', 'number' => '0634378675')
);
Now I have this number: 0634345675
.
How can I check If this number exists in the array $array
?
I tried to do this:
if(!in_array('0634345675', $array)){
// insert into DB
}
But this keeps adding multiple of the same rows.
Does anyone knows how to check if this number exists in $array
?
Full code:
foreach($DN as $number){ // $DN got ['0634345675', '0632545675', '0614342375']
if(!in_array($number, $array)){
// insert into DB
}
}