Reputation:
$a['id'] = 124;
$b['id'] = '124';
if ($a['id'] == $b['id']) {}
In this case I want id`s are equals. How to properly compare string and int as int? Is there elegant way?
Upvotes: 0
Views: 117
Reputation: 6565
Parse the string value to integer like this:
if($a['id'] == (int)$b['id']) {
// notice `(int)` which will make the '124' to int 124
}
Upvotes: 1