Write a PHP program to create a new array containing the middle elements from the two given arrays of integers, each length 5
<?php function test($nums1, $nums2) { return [$nums1[2], $nums2[2]]; } $nums1 = [10, 20, -30, -40, 30]; $nums2 = [10, 20, 30, 40, 30]; echo "Original array1: " . implode(',', $nums1) . "\n"; echo "Original array2: " . implode(',', $nums1) . "\n"; $result = test($nums1, $nums2); echo "New array: " . implode(',', $result);
Sample Output:
Original array1: 10,20,-30,-40,30 Original array2: 10,20,-30,-40,30 New array: -30,30
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer