PHP Programs

Our aim is to connect students from campuses all over Delhi by making them aware of all Technical, Cultural, Management fests, workshops, Seminars organized by every college in Delhi.

Join Us Now

Program 34: Write a program to copy all the elements of one array into another array.


<!DOCTYPE html>  
	<title>PHP Programs</title>
		$a1 = array(11,12,13,14,15);
		$a2 = array();      

		for ($i = 0; $i < count($a1); $i++) 
				$a2[$i] = $a1[$i];   

		print("Elements of original array - a1 : <br>");  
		for ($i = 0; $i < count($a1); $i++) 
			print($a1[$i] . " ");  
		print("Elements of new array - a2 after copying all the elements from first array  : <br>");  
		for ($i = 0; $i < count($a2); $i++) 
			print($a2[$i] . " ");  

If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.