NaGGi Posted May 4, 2010 Share Posted May 4, 2010 I have following if statement: if ( '$shipping_rate_id' == 'standard_shipping%7CMatkahuolto%7CMatkahuolto%7C6.90%7C3') { Numbers in the end of that mess can change though and I'd like to write the if statement so that the numbers can change without giving problems. So is it possible to add regexp in there somehow? Or any other ideas how to code it? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 4, 2010 Share Posted May 4, 2010 Yes, use preg_match. Quote Link to comment Share on other sites More sharing options...
NaGGi Posted May 4, 2010 Author Share Posted May 4, 2010 Uhm I'm a bit noob with PHP so how that should be coded there? Like if I just wanna check if that word 'Matkahuolto' is in that $shippin_rate_id variable it would echo something? Edit: Guess this works if those end numbers change: if ( preg_match('/standard_shipping%7CMatkahuolto%7CMatkahuolto%7C....%7C./',$shipping_rate_id)) { Looks crappy though. Quote Link to comment Share on other sites More sharing options...
NaGGi Posted May 4, 2010 Author Share Posted May 4, 2010 Got it: if ( preg_match('/^.*Matkahuolto.*$/',$shipping_rate_id)) { Quote Link to comment 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.