Created
March 23, 2021 05:32
-
-
Save gnanasekaran08/cd219837263337197229117f5132913c to your computer and use it in GitHub Desktop.
Splice Associative Array method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = splice_associative_array($args, $index, $content); | |
if (!function_exists('splice_associative_array')) { | |
function splice_associative_array($original_data, $position, $replacement_array) | |
{ | |
/** | |
* Appending the $replacement_array array in $original_data array, set the $position ad -1. | |
* Add the $replacement_array array in top of the $original_data array, then set the $position as 0. | |
* | |
*/ | |
$data = array_slice($original_data, 0, $position, true) + | |
$replacement_array + | |
array_slice($original_data, 0, count($original_data), true); | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment