oracle765 Posted February 8, 2014 Share Posted February 8, 2014 Hi Professionals I am trying to validate a policy type variable and I am not sure which way to go around it, is there a better way through a switch or case statement or something code attached and thanks in advance policytype.txt Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/ Share on other sites More sharing options...
mac_gyver Posted February 8, 2014 Share Posted February 8, 2014 (edited) it kind of depends on if there are or can be other values accross in any set and if there are or can be other values down with 5,...10... or higher? and do you need to validate that the values being tested are only in those sets of values or is just getting the number from the end enough? Edited February 8, 2014 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/#findComment-1468156 Share on other sites More sharing options...
oracle765 Posted February 8, 2014 Author Share Posted February 8, 2014 I am not sure what you mean by 5 10 or higher that is the only values there are Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/#findComment-1468158 Share on other sites More sharing options...
mac_gyver Posted February 8, 2014 Share Posted February 8, 2014 based on your reply - $policytypeid = substr($policytypeid, -1); Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/#findComment-1468163 Share on other sites More sharing options...
oracle765 Posted February 8, 2014 Author Share Posted February 8, 2014 hi Mac_gyver I have no idea what you mean lol so I can do switch if $policytypeid = substr($policytypeid, -1); then ?? Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/#findComment-1468168 Share on other sites More sharing options...
Ch0cu3r Posted February 8, 2014 Share Posted February 8, 2014 so I can do switch if $policytypeid = substr($policytypeid, -1); then ?? No, because that is not valid syntax, Mac_gyver code will will return the last character from the string stored in $policytypeid. So if $policytypeid is set to FamilyR2 then substr($policytypeid, -1); will return 2. Quote Link to comment https://forums.phpfreaks.com/topic/286034-validate-either-if-or-switch-case/#findComment-1468174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.