array each function - returns current key & value pair and advance cursor
each-example-in-php.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>array each function - returns current key & value pair and advance cursor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Md Iqbal Hosan">
<meta name="title" content="array each function - returns current key & value pair and advance cursor">
<meta name="keywords" content="php, example, code, array, function, each">
<meta name="description" content="array each function - returns current key & value pair and advance cursor">
<style>
h2, h4{background:#ccc; color:#000066;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:16px;}
body{ background:#FFFFFa;}
</style>
</head>
<body>
<h2>array each function - returns current key & value pair and advance cursor</h2>
<pre>
<?php
/*
--------------------------------------------------------------
let us make an array and fill it up with some keys and values
--------------------------------------------------------------
*/
$myArray = array("a"=>"apple", "b"=>"book", "c"=>"cat", "z"=>"zoo");
echo "<h4>Output of myArray</h4>";
print_r($myArray);
/*
-------------------------------------------------------------------------------------
we want to get the each element of the array by using each function
-------------------------------------------------------------------------------------
*/
$eachArray = each($myArray);
echo "<h4>Output of eachArray using each function</h4>";
print_r($eachArray);
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..