I want to search in large piece of texts for different strings and if the match found for each string it return me a special string (not the matched string).
there are almost 150 different string I want to search them in the thousand text files. I write this code
foreach($countries as $cont)
{
if(stripos($text,$cont))
{
$country=$cont;
and here is a few line of countries.php (I include this file) :
$countries['AD'] = 'Andorra';
$countries['AE'] = 'United Arab Emirates';
$countries['AF'] = 'Afghanistan';
$countries['AG'] = 'Antigua And Barbuda';
$countries['AI'] = 'Anguilla';
$countries['AL'] = 'Albania';
For example I want to print 'Arabian' when it was a match for 'United Arab Emirates'...
take a look here: http://www.php.net/manual/en/function.preg-match-all.php
Pass each text to this function, alongside every match you're looking for (in an array) and another array where to put all the matches.
Then you can do whatever you want with all the matches you found.