chantown Posted November 28, 2007 Share Posted November 28, 2007 Hi, Let's say I have an array of words 0=>"hello" 1=>"php" 2=>"bad" 3=>"programming" And then I have a string of text (from a textarea or something) ------hello, Programming is very fun i love c++ and it's great language.------ Is there any special function I can use to "scan" this text and see if there are the keywords in this array, and if so, store them in an array? For example, in this case, "hello" and "programming" would be the result after the "scan" Link to comment https://forums.phpfreaks.com/topic/79185-solved-finding-keywords-from-text/ Share on other sites More sharing options...
~n[EO]n~ Posted November 28, 2007 Share Posted November 28, 2007 Assuming you have a textarea named texts you can try like this <?php if (isset($_POST['submit'])) // when user press submit btn { $arr = array(0 => "hello", 1 => "php", 2 => "bad" , 3 => "programming"); //your array of texts $string = $_POST['texts']; // get value from text box $string = split (" ", $string); foreach ($string as $v) { //echo "Current value of \$string: $v.\n"; if (in_array($v, $arr)) { echo "Got $v <br />"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/79185-solved-finding-keywords-from-text/#findComment-400848 Share on other sites More sharing options...
chantown Posted November 28, 2007 Author Share Posted November 28, 2007 yes, thank you very much! SPLIT was the function i was looking for Link to comment https://forums.phpfreaks.com/topic/79185-solved-finding-keywords-from-text/#findComment-400853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.