PHP 8.3.21 Released!

Voting

: max(five, five)?
(Example: nine)

The Note You're Voting On

news_yodpeirs at thoftware dot de
13 years ago
Sometimes you may want to insert one array into another and just work on with the resulting array. array_splice() doesn't support this, as the resulting array isn't the returned value but the first argument, which is changed by reference.

Therefore you may use the following function, which inserts array $ins in array $src at position $pos. $rep can be used if $ins shouldn't be just inserted, but should replace some existing elements (the number of elements to be replaced is given in $rep).

<?php
function array_insert($src,$ins,$pos,$rep=0) {
array_splice($src,$pos,$rep,$ins);
return(
$src);
}
?>

<< Back to user notes page

To Top