51 foreach ( $array
as $elt ) {
52 $hashes[$elt] = md5( $elt . $separator . $key );
54 uasort( $array,
function ( $a, $b ) use (
$hashes ) {
67 if ( !is_array( $weights ) || count( $weights ) == 0 ) {
71 $sum = array_sum( $weights );
73 # No loads on any of them
74 # In previous versions, this triggered an unweighted random selection,
75 # but this feature has been removed as of April 2006 to allow for strict
76 # separation of query groups.
79 $max = mt_getrandmax();
80 $rand = mt_rand( 0, $max ) / $max * $sum;
83 foreach ( $weights
as $i => $w ) {
85 # Do not return keys if they have 0 weight.
86 # Note that the "all 0 weight" case is handed above
87 if ( $w > 0 && $sum >= $rand ) {
112 public static function findLowerBound( $valueCallback, $valueCount, $comparisonCallback, $target ) {
113 if ( $valueCount === 0 ) {
120 $mid = $min + ( ( $max - $min ) >> 1 );
121 $item = call_user_func( $valueCallback, $mid );
122 $comparison = call_user_func( $comparisonCallback, $target, $item );
123 if ( $comparison > 0 ) {
125 } elseif ( $comparison == 0 ) {
131 }
while ( $min < $max - 1 );
134 $item = call_user_func( $valueCallback, $min );
135 $comparison = call_user_func( $comparisonCallback, $target, $item );
136 if ( $comparison < 0 ) {
158 $arrays = func_get_args();
159 array_shift( $arrays );
162 foreach ( $array1
as $key =>
$value ) {
163 if ( is_array(
$value ) ) {
165 foreach ( $arrays
as $array ) {
166 if ( isset( $array[$key] ) ) {
167 $args[] = $array[$key];
170 $valueret = call_user_func_array( __METHOD__,
$args );
171 if ( count( $valueret ) ) {
172 $ret[$key] = $valueret;
175 foreach ( $arrays
as $array ) {
176 if ( isset( $array[$key] ) && $array[$key] ===
$value ) {