41 $arrayEnd = array_splice( $arr, $index );
42 $arrayStart = array_splice( $arr, 0, $index );
43 return ( array_merge( $arrayStart, array( $key => $val ), $arrayEnd ) );
63 public static function insert( &$arr, $new, $index = 0 )
66 $arrayEnd = array_splice( $arr, $index );
67 $arrayStart = array_splice( $arr, 0, $index );
68 return ( array_merge( $arrayStart, $new, $arrayEnd ) );
83 public static function prepend( $array, &$dest )
85 $dest = self::insert( $dest, $array );
101 public static function append( $array, &$dest )
103 $dest = self::insert( $dest, $array, count( $dest ) );
120 foreach ( $array as $element ) {
121 $result[] = array( $element );
138 public static function arrayMatch( $array_keys, $array_match )
141 foreach ( $array_match as $key => $value ) {
142 if ( in_array( $key, $array_keys ) ) {
143 $result[$key] = $value;
162 return self::arrayMatch( array_values( $array ), $array_match );
178 return self::arrayMatch( array_keys( $array ), $array_match );
197 $json = json_encode( $array );
200 $object = json_decode( $json );
218 $json = json_encode( $object );
221 $array = json_decode( $json,
true );
239 $keys = array_keys( $keeplist );
240 foreach ( $source as $key => $value ) {
241 if ( !in_array( $key, $keys ) ) {
242 unset( $source[$key] );
260 public static function fit( $source, $defaults )
262 $source = self::stripKeys( $source, $defaults );
263 return array_merge( $defaults, $source );
281 public static function httpBuildQuery( $formdata, $numeric_prefix = null, $arg_separator = null )
285 if ( defined(
'PHP_MAJOR_VERSION' ) && PHP_MAJOR_VERSION >= 5 ) {
286 return http_build_query( $formdata, $numeric_prefix, $arg_separator );
289 $version = absint( phpversion() );
290 if ( !empty( $version ) && $version >= 5 ) {
291 return http_build_query( $formdata, $numeric_prefix, $arg_separator );
298 foreach ( $formdata as $key => $value ) {
299 $result .= sprintf(
'%s%s=%s', $amp, $key, urlencode( $value ) );
300 $amp = $arg_separator;
326 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.4.8',
'arrayMatch()' );
328 $keys = array_keys( $array_key );
330 foreach ( $array_extract as $key => $value ) {
331 if ( in_array( $key, $keys ) ) {
332 $result[$key] = $value;
351 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.4.8',
'arrayMatch()' );
353 $keys = array_keys( $arrayKeys );
355 foreach ( $sourceArray as $key => $value ) {
356 if ( in_array( $key, $keys ) ) {
357 $result[$key] = $value;