jamesxg1 Posted March 26, 2010 Share Posted March 26, 2010 Hiya peeps! $input= 'hiya, how are you?'; $match = array('how are you') $output = array(); foreach($match as $sentence_split): $sentence_split_slash = '/' . $sentence_split . '/'; if(preg_match($sentence_split_slash, $input)): $output[] = $sentence_split; else: $this->conversate_word($sentence_split); endif; endforeach; how do I make it so that the 'hiya' is actually sent to $this->conversate_word(); Many thanks James. Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 26, 2010 Share Posted March 26, 2010 $input= 'hiya, how are you?'; $match = array('how are you'); $output = array(); foreach($match as $sentence_split) { $sentence_split_slash = '/' . $sentence_split . '/'; if(preg_match($sentence_split_slash, $input)) { $output[] = $sentence_split; //Replace array $replace = array(',', '?', $sentence_split); $conv_word = trim(str_replace($replace, "", $input)); $this->conversate_word($conv_word); } } I just assumed you would want the , and the ? to be removed as well so I added those into the replace array. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted March 26, 2010 Author Share Posted March 26, 2010 Hiya bud, Cheers for the reply, I already strip the text of special characters, but cheers for the help bud, and it didnt work unfortunatly :S. Many thanks James. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted March 26, 2010 Author Share Posted March 26, 2010 BUMP. Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 27, 2010 Share Posted March 27, 2010 Hmmm... if I replace $this->conversate_word($conv_word); with echo $conv_word; the result is "hiya" so it is being passed to the conversate_word method... what isn't working? 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.