Home Blog Page 48

Break : PHP Manual

break break ends execution of the current for, foreach, while, do-while or switch structure. break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.   <?php $arr = array('one', 'two', 'three', 'four', 'stop', 'five'); while (list(, $val) = each($arr)) {     if ($val == 'stop') {         break;    /* You could also write 'break 1;' here. */     }     echo "$val<br />n"; } /* Using the optional argument. */ $i = 0; while (++$i) {     switch ($i) {     case 5:         echo "At 5<br />n";         break 1;  /* Exit only the switch. */     case 10:         echo "At 10; quitting<br />n";         break 2;  /* Exit the switch and the while. */     default:         break;     } } ?>

Foreach loop : PHP Manual

foreach PHP 4 introduced a foreach construct, much like Perl and some other languages. This simply gives an easy way to iterate over arrays. foreach works only on arrays,...

For Loop : PHP Manual

for for loops are the most complex loops in PHP. They behave like their C counterparts. The syntax of a for loop is: for (expr1; expr2; expr3) ...


while while loops are the simplest type of loop in PHP. They behave just like their C counterparts. The basic form of a while statement is: while (expr) ...


do-while do-while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning. The main...

Search and replace on a string

This example uses the str_replace function to replace some text in a string with another piece of text. <?php //using str_replace in php //our message $msg = "this...

Display a pages Meta Tags

This uses the get_meta_tags function to display the meta tags of a given page . <?php $searchmeta = get_meta_tags("index.htm"); echo ($searchmeta); echo ("<br>"); echo ($searchmeta); ?>

Get Users IP address

Get users IP address <?php echo $REMOTE_ADDR; ?>

Do While loop example

This is a Do while loop example in PHP, similar to the while loop earlier <?php $i=0; do { $i++; echo "$i<br>"; } while ($i<5); ?>

While loop

This is the most basic example of a While loop in PHP <?php $i=1; while($i<=5) { echo "$i<br>"; $i++; } ?>
SEO Powered by Platinum SEO from Techblissonline