Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.

Get Started Now!

Merge Two Sorted Arrays: Write a PHP function to merge two sorted arrays into a single sorted array.

function mergeSortedArrays($arr1, $arr2) {
    return array_merge($arr1, $arr2);
}

// Example usage:
$array1 = [1, 3, 5];
$array2 = [2, 4, 6];
$result = mergeSortedArrays($array1, $array2);
sort($result); // Sorting the merged array
print_r($result);

Related Posts

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Artificial Intelligence