horseatingweeds Posted July 31, 2007 Share Posted July 31, 2007 I have a function for converting state codes into names. However, some state codes I don't know of and the way I have the input allows people to put in a state. So, I was wondering if a variable, in this case a state code, is inputed into the function that turns up undefined I can have a statement to handle it and basically have it ignored and printed as the person typed it. Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/ Share on other sites More sharing options...
clearstatcache Posted July 31, 2007 Share Posted July 31, 2007 pls show ur code.... Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/#findComment-311663 Share on other sites More sharing options...
btherl Posted July 31, 2007 Share Posted July 31, 2007 Something like this? $name = state_to_name($state); if ($name === null) { $name = $state; } Assuming your state_to_name() returns null if no match is found Link to comment https://forums.phpfreaks.com/topic/62611-is-there-a-way-to-make-an-if-statment-for-something-undefined/#findComment-311704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.