peter11 Posted August 13, 2010 Share Posted August 13, 2010 Why is this not correct? <?php $newphrase = 1234567; echo (max($newphrase)); ?> Link to comment https://forums.phpfreaks.com/topic/210638-max-quetion/ Share on other sites More sharing options...
JonnoTheDev Posted August 13, 2010 Share Posted August 13, 2010 Because the function max() takes an array, or series of values as its parameter, not a string. i.e echo max(1,2,3,4); echo max(array(1,2,3,4)); Link to comment https://forums.phpfreaks.com/topic/210638-max-quetion/#findComment-1098834 Share on other sites More sharing options...
peter11 Posted August 13, 2010 Author Share Posted August 13, 2010 how can i show the highest number in the string? Link to comment https://forums.phpfreaks.com/topic/210638-max-quetion/#findComment-1098839 Share on other sites More sharing options...
newbtophp Posted August 13, 2010 Share Posted August 13, 2010 how can i show the highest number in the string? <?php $newphrase = 1234567; preg_match_all('~\d{1}~', $newphrase, $a); echo max($a[0]); ?> Link to comment https://forums.phpfreaks.com/topic/210638-max-quetion/#findComment-1098842 Share on other sites More sharing options...
JonnoTheDev Posted August 13, 2010 Share Posted August 13, 2010 <?php $newphrase = 1234567; echo max(str_split($newphrase)); ?> Link to comment https://forums.phpfreaks.com/topic/210638-max-quetion/#findComment-1098843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.