l_kris06 Posted August 15, 2008 Share Posted August 15, 2008 Hi all, I have a text file which i need to read line by line and fetch a certain info from that line, for example. [CISC26907] Digits are not heard properly over H.323 [CISC26928] Digits are not heard properly when G.729 codec is used . . .etc I need only the CISC26907 and CISC26928 and other such ID's contained in the file. I can read line by line, but i am unable to retrieve specific info from a line. can somebody pls help me? Rgds, kris Link to comment https://forums.phpfreaks.com/topic/119896-php-file-parsing/ Share on other sites More sharing options...
turkman Posted August 15, 2008 Share Posted August 15, 2008 try $text; //contains the line from the file $openChar = strrpos("text","["); $closeChar = strrpos("text","]"); $Tag = substr($text,$openChar,closeChar); //Tag should contain the id number Link to comment https://forums.phpfreaks.com/topic/119896-php-file-parsing/#findComment-617648 Share on other sites More sharing options...
moselkady Posted August 15, 2008 Share Posted August 15, 2008 You can try this: <?php $line = '[CISC26907] Digits are not heard properly over H.323'; echo ereg_replace(".*(\[CISC[0-9]+\]).*", "\\1", $line); ?> Link to comment https://forums.phpfreaks.com/topic/119896-php-file-parsing/#findComment-617651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.