AndrewFerrara Posted January 28, 2011 Share Posted January 28, 2011 I need an if statement, but i have no idea how or if it can be done. If a text string is greater than 10 characters, {echo $string} else{ print $error } <?php $string = '1900800008'; $error = 'String isn't long enough'; if( ????????? ){echo $string} else{ print $error } ?> Link to comment https://forums.phpfreaks.com/topic/225936-string-if-statement/ Share on other sites More sharing options...
QuickOldCar Posted January 28, 2011 Share Posted January 28, 2011 <?php $string = "1900800008"; $string_length = strlen($string); if ($string_length >= 10) { echo $string; } else { echo "String isn't long enough"; } ?> Link to comment https://forums.phpfreaks.com/topic/225936-string-if-statement/#findComment-1166434 Share on other sites More sharing options...
AndrewFerrara Posted January 28, 2011 Author Share Posted January 28, 2011 For some reason thats not working correctly.. Link to comment https://forums.phpfreaks.com/topic/225936-string-if-statement/#findComment-1166439 Share on other sites More sharing options...
QuickOldCar Posted January 28, 2011 Share Posted January 28, 2011 Just tried it with 3 different numbers and works. http://get.blogdns.com/test-code.php Link to comment https://forums.phpfreaks.com/topic/225936-string-if-statement/#findComment-1166441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.