Re: Open a file

From: Date: Sun, 18 May 2003 04:19:20 +0000
Subject: Re: Open a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148068@lists.php.net to get a copy of this message
try: $fp=fopen("some_file_name.txt","r") while (!feof($fp) { $line=fgets($fp,100); // 100 or however long the lines are. if (preg_match("/<script>/",$line)) { while (!preg_match("/</script>/",$line)) { $line.=fgets($fp,100); } } } list ($junk,$stuff_to_save)=split ("<script>",$line,2); list ($stuff_to_save,$junk)=split ("</script>",$stuff_to_save, 2); fclose($fp); echo $stuff_to_save; The above script should get the text between the start script and stop script tags. There's likely a more elegant way to do this though. Hugh ----- Original Message ----- From: "shaun" <shaun@mania.plus.com> To: <php-general@lists.php.net> Sent: Saturday, May 17, 2003 3:44 PM Subject: [PHP] Open a file > Hi, > > How can i open a file and get the contents of everything in the file that > lands between the <script> </script> tags, to place in a textarea? > > Thanks for your help > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#148068) next »