<?php function insertAtPosition($array, $item, $position) { array_splice($array, $position, 0, $item); return $array; } $arr = [1, 2, 3, 4, 5]; $item = 99; $position = 2; // Change this to insert at a different position $newArray = insertAtPosition($arr, $item, $position); echo "Updated Array: " . implode(", ", $newArray); ?>