Jump to content

Wildcard?


ERuiz

Recommended Posts

I have a script which receives _POST data from a program. I need to make sure that any data that has 747 in it, will be given a value I determine.

 

I was thinking about something along these lines:

 

 

$aircraft = $_POST[aircraft];

 

if ($aircraft == "%747%") {

 

$aircraft = "B747";

 

}

 

Would that work? I was thinking along the lines of the mySql LIKE commands where a % would be a wildcard. In other words, I want to check the variable $aircraft and if this variable has any reference to "747" (ej. Boeing747 or B747-200, et etc), then it will simply make it "B747".

 

Thanks for any help...

 

ERuiz

 

Link to comment
Share on other sites

You actually use a function for this:

 

$aircraft = $_POST[aircraft];
$similar = strpos($aircraft, '747');

if($similar || $aircraft == "747") {
$aircraft = "B747";
}

 

In strpos, the first argument is the variable to search in and the second is what to search for. It returns a true if it could find it, a false if it couldn't.

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.