Answer the question
In order to leave comments, you need to log in
Why doesn't it swap array elements?
$arr = ['10','12','15','19','20'];
$min = min( $arr );
$max = max( $arr );
$min_index = intval(array_search($min, $arr));
$max_index = intval(array_search($max, $arr));
$arr[ $max_index ] = $min ;
$arr[ $min_index ] = $max;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question