latino.ad7 Posted February 26, 2010 Share Posted February 26, 2010 If I want my variable to begin with abc, how do I code that? In SQL you add % sign at the end, but how to do it in PHP? $var[0] = 'abcdef'; $var[1] = 'xyzxyz'; if ($var[$value] == 'abc%') { echo 'ok'; } else { echo 'not ok'; } Link to comment https://forums.phpfreaks.com/topic/193484-how-to-refer-to-the-beginning-of-text-string/ Share on other sites More sharing options...
alpine Posted February 26, 2010 Share Posted February 26, 2010 <?php $data = "ABCDEF"; if(substr($data,0,3) == "ABC") ?> Link to comment https://forums.phpfreaks.com/topic/193484-how-to-refer-to-the-beginning-of-text-string/#findComment-1018595 Share on other sites More sharing options...
latino.ad7 Posted February 26, 2010 Author Share Posted February 26, 2010 Yes, thats it. Thanks. Link to comment https://forums.phpfreaks.com/topic/193484-how-to-refer-to-the-beginning-of-text-string/#findComment-1018605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.