Hello Friends,
All we know about array_merge(param1,param2) array function in PHP. It may be possible that some begineers didn't come across this function. For those people, array_merge(param1,param2) will merge two arrays and reindex all elements in array.
<?php
$merged_array = array_merge($firstarray,$secondarray);
?>
Above code will merge both array ($firstarray and $secondarray) in $merged_array and reindex all element starting from zero index.
But there are some cases in which you need to keep the same indexes(preserve numeric keys) of this arrays in newly created merged array. For this situation you can't go for array_merge function. You can simply use '+' operator and it will append both arrays without reindexing elements.
<?php
$merged_array = $firstarray + $secondarray;
?>
This are the two ways in which you can merge two arrays with reindexing and without reindexing.Look at below links for solutions.
To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.