php - How to match string based string on text file -


simply in php replace string other string such using particular function, str_replace (), etc

suppose have file.txt contains

text1 text2 text3 ... text n 

and have variable $text like

$text = "i want text1 , text2"; 

how strings (text1 , text2) based on available strings in file.txt?

i want have new variable ($new) contains strings of $text fits on string file.txt

so have $new="text1 text2";

i still confused, how adjust 2 text.

any wouldbe appreciated. thanks.

do this:

$filetokens = explode(php_eol, file_get_contents('file.txt')); $texttokens = explode(' ', "i want text1 , text2");  $results = array_intersect($filetokens, $texttokens); var_dump($results); 

to results space-delimited string, use line

$stringresults = implode(' ', $results); var_dump($stringresults); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -