Jump to content

Match & remove from string. Help.


jamesxg1

Recommended Posts

Hiya peeps,

 

I'm totally lost here I just cant figure it out. This is what I need to do.

 

$input = 'hiya how are you doing today';
$match = array('how are you');

// foreach check if 'how are you' is in $input.
// if it is remove it from the string a send the rest to $this->output('THE REST OF THE STRING');
// if it doesnt match then call $this->conversate_word($input);

 

Many thanks

 

James.

Link to comment
Share on other sites

foreach ($match as $string) {
    if (stristr($string, $input) !== false) {
         $input = str_replace($string, "", $input);
    }
}
echo $input;

 

Hiya bud,

 

Cheers for the reply mate, it didnt work :S.

 

Many many thanks

 

James

Link to comment
Share on other sites

Figure it out for yourself, this nonsense of "it does not work" is just bs. Flipping the $string and $input should make it work, which you could have found out by reading the manual for stristr as well which would have helped you out. How do you think everyone here who answers questions know how to do it? The learned it by reading, trying and failing.

 

If you do not want to code it yourself then don't. Find someone else to code it and pay them. If you do, read and try stuff out for yourself.

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.