Jump to content

Adding regexp inside if statement?


NaGGi

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/200643-adding-regexp-inside-if-statement/
Share on other sites

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.