PHP Performing action on a variable line by line -
i have variable containing html code , want perform action of every line of code:
<?php $html = file_get_contents('http://www.google.com/'); #how (not real commands) /* $line = 1 $currentline = readline($html,$line) line++ $html variable want read line $line line number , $currentline contents if $line 1 $currentline <html> or whatever after perform things on line , go on reading each line untill read lines */ ?>
i hope understand mean/need. i’m new web based programming need lot of explanation!
please don’t utilize technical terms think php programmer should know because don't know is.
your question similar this one although 1 might argue whether answers understandable beginner. should you're looking for:
<?php $html = file_get_contents('http://www.google.com/'); // skipped: error checks // split $html lines $lines = explode("\n", $html); // iterate on lines foreach($lines $line) { // process $line } // or 5th line $fifth_line = $lines[4]; // or iterate using index for($line = 0; $line < count($lines); $line++) { $theline = $lines[$line]; }
php line-by-line
No comments:
Post a Comment