The while loops are used to repeat a block of code as long as a specified condition is true.
The while loops have the following syntax:
while (condition) { // codeBlock }- If the condition is true, the code within curly brackets is executed, then the script checks again the condition, and if it is still true, "codeBlock" is executed again. This process continues until condition becomes false, or you use a "break" statement to end the loop.
var total:int = 1; // define a variable (counter) to control the executions number var i:int=0; // create a while loop while(i<4) { total *= 2; trace(total); i++; // adds 1 to counter (i) } // In Output displays: 2 4 8 16ActionScript first evaluates the condition (i<4), becouse "i=0", this condition returns true; so, ActionScript executes the loop body.
do { // codeBlock } while (condition);Example:
var total:int = 1; // define a variable (counter) to control the executions number var i:int=1; // create a do..while loop do { total *= 2; trace('total is '+ total); i++; // adds 1 to counter (i) } while(i<0); // In Output displays: total is 2This code displays in Output panel: total is 2
<ul> <li>http://coursesweb.net/html/</li> <li>http://coursesweb.net/css/</li> </ul>
.some_class { display: list-item; }
var obj = { "courses": ["php", "javascript", "ajax"] }; var jsonstr = JSON.stringify(obj); alert(jsonstr); // {"courses":["php","javascript","ajax"]}
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>'; $dochtml = new DOMDocument(); $dochtml->loadHTML($strhtml); $elm = $dochtml->getElementById("dv1"); echo $elm->nodeValue; // CoursesWeb.net