treeleaf20 Posted August 24, 2011 Share Posted August 24, 2011 All, I have a zip code and for example the zip code is 01101. How can I determine if the first character in this is a zero? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/245608-determine-if-the-first-character-is-a-0/ Share on other sites More sharing options...
requinix Posted August 24, 2011 Share Posted August 24, 2011 Try using substr. Link to comment https://forums.phpfreaks.com/topic/245608-determine-if-the-first-character-is-a-0/#findComment-1261483 Share on other sites More sharing options...
Maq Posted August 24, 2011 Share Posted August 24, 2011 All, I have a zip code and for example the zip code is 01101. How can I determine if the first character in this is a zero? Thanks in advance. There are a multitude of ways to do this. Another way: $zip = "01101"; echo $zip[0]; Link to comment https://forums.phpfreaks.com/topic/245608-determine-if-the-first-character-is-a-0/#findComment-1261487 Share on other sites More sharing options...
AbraCadaver Posted August 24, 2011 Share Posted August 24, 2011 if(strpos($zip, '0') === 0) { //yes } Link to comment https://forums.phpfreaks.com/topic/245608-determine-if-the-first-character-is-a-0/#findComment-1261490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.