Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll 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