Answers for "ksort php"

PHP
10

php sort array by key

$weight = [
    'Pete' => 75, 
    'Benjamin' => 89,
    'Jonathan' => 101
  ];  	
  ksort($weight);
Posted by: Guest on December-04-2019
0

usort in php

<?php

 function my_sort($a,$b)
{
if ($a==$b) return 0;
return ($a<$b)?-1:1;
}

$a=array(4,2,8,6);
usort($a,"my_sort");
?>
Posted by: Guest on May-20-2021
-1

php rtrim

$colors=trim("blue,red,green,",",");//remove last , with rtrim
Posted by: Guest on November-20-2020

Browse Popular Code Answers by Language