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
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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.