Answers for "add data to the same array php"

PHP
3

how to add two array in single array without repetation in php

<?php
	$array1=array("CPU","Mouse","Monitor");
	$array2=array("Key-Board","Monitor","Printer");
	$array = array_unique(array_merge($array1, $array2));
	print_r($array);
?>
Posted by: Guest on October-24-2020
2

php add array values with same keys

$sumArray = array();

foreach ($myArray as $k=>$subArray) {
  foreach ($subArray as $id=>$value) {
    $sumArray[$id]+=$value;
  }
}

print_r($sumArray);
Posted by: Guest on June-11-2021

Code answers related to "add data to the same array php"

Browse Popular Code Answers by Language