Skip to main content

Create array element by element

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
Create simple array in php  <?php
 // create array element by element
 $saddam[0]="saddam";
 $saddam[1]="sanjay";
 $saddam[2]="hitesh";
 $saddam[3]="sanjay";
 $saddam[4]="kuldip";
 echo "my group friends name is ";
 for($i=0;$i<=4;$i++){
     echo $i." ". $saddam[$i]."</br>";
   
     }
 ?>
</body>
</html>


output should be like this :-

 create simple array in php my group friends name is 0 saddam
1 sanjay
2 hitesh
3 sanjay
4 kuldip

Comments