53 foreach ( $array as $elt ) {
54 $hashes[$elt] = md5( $elt . $separator . $key );
56 uasort( $array,
static function ( $a, $b ) use ( $hashes ) {
57 return strcmp( $hashes[$a], $hashes[$b] );
69 if ( !is_array( $weights ) || count( $weights ) == 0 ) {
73 $sum = array_sum( $weights );
75 # No loads on any of them
76 # In previous versions, this triggered an unweighted random selection,
77 # but this feature has been removed as of April 2006 to allow for strict
78 # separation of query groups.
81 $max = mt_getrandmax();
82 $rand = mt_rand( 0, $max ) / $max * $sum;
85 foreach ( $weights as $i => $w ) {
87 # Do not return keys if they have 0 weight.
88 # Note that the "all 0 weight" case is handed above
89 if ( $w > 0 && $sum >= $rand ) {
115 $comparisonCallback, $target
117 if ( $valueCount === 0 ) {
124 $mid = $min + ( ( $max - $min ) >> 1 );
125 $item = $valueCallback( $mid );
126 $comparison = $comparisonCallback( $target, $item );
127 if ( $comparison > 0 ) {
129 } elseif ( $comparison == 0 ) {
135 }
while ( $min < $max - 1 );
138 $item = $valueCallback( $min );
139 $comparison = $comparisonCallback( $target, $item );
140 if ( $comparison < 0 ) {
163 foreach ( $array1 as $key => $value ) {
164 if ( is_array( $value ) ) {
166 foreach ( $arrays as $array ) {
167 if ( isset( $array[$key] ) ) {
168 $args[] = $array[$key];
172 if ( count( $valueret ) ) {
173 $ret[$key] = $valueret;
176 foreach ( $arrays as $array ) {
177 if ( isset( $array[$key] ) && $array[$key] === $value ) {
213 $numInputs = count( $inputArrays );
214 if ( $numInputs === 0 ) {
219 foreach ( $inputArrays as &$inputArray ) {
220 if ( !count( $inputArray ) ) {
223 reset( $inputArray );
225 unset( $inputArray );
232 foreach ( $inputArrays as $inputArray ) {
233 $element[] = current( $inputArray );
235 $outputArrays[] = $element;
242 for ( $paramIndex = $numInputs - 1; $paramIndex >= 0; $paramIndex-- ) {
243 next( $inputArrays[$paramIndex] );
244 if ( key( $inputArrays[$paramIndex] ) ===
null ) {
245 reset( $inputArrays[$paramIndex] );
253 return $outputArrays;
258class_alias( ArrayUtils::class,
'ArrayUtils' );