Non Numerically Indexed Array
Saturday, March 19, 2022
Comment
Non Numerically Indexed Array
<html>
<body>
<form action="assoc2.php" method="post">
<center>
<h1>Non Numerically Indexed Array</h1>
<font size="5">
Enter the Subjects aand Marks for first student:<br>
<table>
<tr>
<th>subject</th>
<th>Marks</th>
</tr>
<tr>
<td><input type="text" name="sub1"></td>
<td><input type="text" name="m1"></td>
</tr>
<tr>
<td><input type="text" name="sub2"></td>
<td><input type="text" name="m2"></td>
</tr>
</table>
<br><br>
Enter the Subjects aand Marks for second student:<br>
<table>
<tr>
<th>subject</th>
<th>Marks</th>
</tr>
<tr>
<td><input type="text" name="sub3"></td>
<td><input type="text" name="m3"></td>
</tr>
<tr>
<td><input type="text" name="sub4"></td>
<td><input type="text" name="m4"></td>
</tr>
</table>
<input type="submit" name="submit">
</font>
</center>
</form>
<?php
if(isset($_POST["submit"]))
{
$sub1=$_POST["sub1"];
$m1=$_POST["m1"];
$sub2=$_POST["sub2"];
$m2=$_POST["m2"];
$sub3=$_POST["sub3"];
$m3=$_POST["m3"];
$sub4=$_POST["sub4"];
$m4=$_POST["m4"];
$arr1=array($sub1=>$m1,$sub2=>$m2);
print_r($arr1);
$arr2=array($sub3=>$m3,$sub4=>$m4);
print_r($arr2);
Baca Juga
if($arr1==$arr2)
{
echo "<br>Both arrays are same:<br>";
$apparr=array_merge($arr1,$arr2);
print_r($apparr);
file_put_contents("filename.txt",print_r($apparr,true));
}
else
{
echo "<br>Both arrays are different:<br>";
$apparr=array_merge_recursive($arr1,$arr2);
print_r($apparr);
file_put_contents("filename.txt",print_r($apparr,true));
}
}
?>
</body>
</html>
0 Response to "Non Numerically Indexed Array "
Post a Comment