Hey i have a txt file and i wanna retrieve data from it using php my txt file is : 50 CENT|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx 2 PAC|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx Antonio garcia|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx ABBA|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx BSB|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx BEYONCE|http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xx ........ i wanna retrieve every group of artists that begins with specific letter and every artist links to his link !! thanks
It would be best to use a database, however if you have to use a txt file. <? $lines = file('myfile.txt'); $letter = "C"; foreach ($lines as $line) { $arry = explode("|",$line); $artist = $arry[0]; $url = $arry[1]; if(strtolower(substr($artist,0,1))== strtolower($letter)){ echo $url . "<br>"; } } ?> PHP: