I have an array that looks as follows :
Array ( [0] => Array ( [bet_type] => 1 [game_id] => 1627895 [bet_id] => 1 [team] => Paris SG [odds] => 29/100 [line] => 0 ) [1] => Array ( [bet_type] => 2 [game_id] => 1642828 [bet_id] => 1 [team] => Derby County [odds] => 19/10 [line] => 0 ) )
I need to check if a "game_id" exists within that array. So for example if 1642828
My current PHP code is as follows :
// Build An array titled Bet
$bet = array(
'0' => array(
'bet_type' => $bet_type,
'game_id' => $game_id,
'bet_id' => $bet_id,
'team' => urldecode($teamname),
'odds' => $odds,
'line' => $bet_line
)
);
$betslip = $this->session->userdata('betslip');
// Create The Betslip For The First Time...
if(empty($betslip))
{
$this->session->set_userdata('betslip', $bet);
}
else
{
// Add To The Betslip Array...
$betslip[] = array(
'bet_type' => $bet_type,
'game_id' => $game_id,
'bet_id' => $bet_id,
'team' => urldecode($teamname),
'odds' => $odds,
'line' => $bet_line
);
$this->session->set_userdata('betslip', $betslip);
}
So my initial try was this :
if(!in_array($game_id, $betslip)
{
// Add To Slip
}
This isn't working is there a way to do an if in_array on a multidimensonal array?
Thanks