sandy1028 Posted July 18, 2007 Share Posted July 18, 2007 Hello, How to search the string after explode $name=$_POST['name'] $lines= file(data.txt); foreach ($lines as $line) { $text_line = explode(":" , $line); } Search the name in $text_line[0] whether the name is present or not Link to comment https://forums.phpfreaks.com/topic/60488-search-string-after-explode/ Share on other sites More sharing options...
cooldude832 Posted July 18, 2007 Share Posted July 18, 2007 please use the [ code ] brackets, anyway <?php $name=$_POST['name'] $lines= file(data.txt); foreach ($lines as $line) { $text_line[] = explode(":" , $line); } foreach($text_line as $value){ if(strchr($value,$name){ $match[] = $value; } print_r($match); Link to comment https://forums.phpfreaks.com/topic/60488-search-string-after-explode/#findComment-300889 Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds 1... <?php $name=$_POST['name'] $lines= file(data.txt); foreach ($lines as $line) { $text_line = explode(":" , $line); if ( strchr($text_line[0] , $name) ) $match[] = $name; } print_r($match); Link to comment https://forums.phpfreaks.com/topic/60488-search-string-after-explode/#findComment-300931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.