php example code : array_fill function in php - fill array with values
array-fill-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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>php example code : array_fill function in php - fill array with values</title>
</head>
<body>
<h3>php example code : array_fill function in php - fill array with values</h3>
<?php
$myValue = 101;
$myArray = array_fill(1, 3, $myValue);
echo "<p style='background:#ddd; color:red;'>Output of my array using array_fill function</p>";
echo "<pre>";
print_r($myArray);
echo "</pre>";
/*
---------------------------------------------------------------------
keys [1], [2], [3] are filled with 101 by using array_fill function
---------------------------------------------------------------------
*/
?>
</body>
</html>

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