I have an array of objects ($response) that looks like this:
Array
(
[0] => stdClass Object
(
[CardNumber] => 5897853070424xxx
[CardHolderName] => P Stoltz
[CardHolderContactNumber] =>
[CardHolderEmailAddress] =>
[CardExpiryDate] => 2017-09-01T00:00:00
[CardHolderTypeID] => 2
[LastUsedDate] => 2017-05-25T00:00:00
)
[1] => stdClass Object
(
[CardNumber] => 589785304326xxx
[CardHolderName] => J Stoltz
[CardHolderContactNumber] =>
[CardHolderEmailAddress] =>
[CardExpiryDate] => 2017-09-01T00:00:00
[CardHolderTypeID] => 2
[LastUsedDate] => 2017-05-25T00:00:00
)
)
Now, I need to unset the entire object where CardNumber != '589785304326xxx'
I have tried this:
$cardnumber = '5897853070424xxx';
foreach( $response as $res )
{
if($res->CardNumber != $cardnumber)
{
unset($res);
}
}
This does nothing. Any suggestions?