Is there a way to extract words from a search bar, for example if someone types: "remind me to eat more veg" so i would be looking for all the words after "to" which in this case would be "eat more veg". I think maybe a regular expression? or is there another way in PHP Thank you for your time.
问问题
41 次
3 回答
0
我认为explode 是一个完全有效的答案,但我喜欢尽可能推广PHP 原生函数。在这种情况下str_word_count
可能更有用。
str_word_count($search_bar_string, 1);
于 2013-03-22T17:42:44.027 回答
0
然后我将 tadaaaa 我的评论作为答案:
explode(' ', $search_bar_string)
我会推荐阅读一本关于 PHP 的书;)
祝你好运!
于 2013-03-22T17:30:25.070 回答
-2
$input_string = "remind me to eat more veg";
$divide_string = "to";
$serch_result = trim ( substr($input_string, strpos($input_string, "to") + strlen($divide_string)) );
于 2013-03-22T17:33:39.943 回答