b0y-101 Mini Shell


Current Path : E:/www3/chiangrai/wp-content/plugins/so-widgets-bundle/base/inc/
File Upload :
Current File : E:/www3/chiangrai/wp-content/plugins/so-widgets-bundle/base/inc/array-utils.php

<?php

/**
 * From this SO answer by Halil Özgür: https://stackoverflow.com/a/18781630/3710600
 *
 * Works with both integer and string positions.
 *
 * @param array      $array
 * @param int|string $position
 * @param mixed      $insert
 */
function siteorigin_widgets_array_insert( &$array, $position, $insert ) {
	if ( is_int( $position ) ) {
		array_splice( $array, $position, 0, $insert );
	} else {
		$pos = array_search( $position, array_keys( $array ) );
		$array = array_merge(
			array_slice( $array, 0, $pos ),
			$insert,
			array_slice( $array, $pos )
		);
	}
}

Copyright © 2019 by b0y-101