Asheeown Posted August 4, 2009 Share Posted August 4, 2009 I have an array value that I want to compare to another array value that is similar but they are both strings. Array value one example: $x[2] = "503"; Array value two example: $y[2] = "500"; Now I want to check if $x[2] is greater than $y[2] and I can't do that when they are strings. The function intval does not work. Link to comment https://forums.phpfreaks.com/topic/168738-solved-string-to-integer/ Share on other sites More sharing options...
play_ Posted August 4, 2009 Share Posted August 4, 2009 settype($x[2], int) Link to comment https://forums.phpfreaks.com/topic/168738-solved-string-to-integer/#findComment-890245 Share on other sites More sharing options...
phpSensei Posted August 4, 2009 Share Posted August 4, 2009 <?php $x = (int)"503"; $y = (int)"500"; if($x > $y){ print "1"; } ?> Link to comment https://forums.phpfreaks.com/topic/168738-solved-string-to-integer/#findComment-890246 Share on other sites More sharing options...
Asheeown Posted August 4, 2009 Author Share Posted August 4, 2009 Both work like a charm, tyvm. Link to comment https://forums.phpfreaks.com/topic/168738-solved-string-to-integer/#findComment-890251 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.