Jump to content
php.lv forumi

multidimensonal array sort


goma smile

Recommended Posts


Sveiki, vai nevarētu man palīdzēt.. tā tad ir masīvs kas gala rezultātā uzģenerējās +- kāds ir lejā.

 

Ka var sortēt masīvu pēc Rates vērtības...

proti ja rates ir mazāks viņš ir augstāk..

Un ir vēl variants ka vairāki rate ir uz vienas

"Economy|Executive|Standard|" un arī viņus attiecīgi no kreisās uz labo..

Array

(

[Economy] => Array

(

[shuttledirect] => Array

(

[0] => Array

(

[Rates] => 382.46

)

 

)

 

)

 

[Executive] => Array

(

[shuttledirect] => Array

(

[0] => Array

(

[Rates] => 567.11

)

 

)

 

)

 

[Standard] => Array

(

[foxtransfer] => Array

(

[0] => Array

(

[Rates] => 289.00

)

 

)

 

)

 

)

 

Edited by goma smile
Link to comment
Share on other sites

var lūdzu mazu piemēru ka ar to usort tu vari vairaku dimensiju masīvā kko sortēt ?

    function sortArray($a, $b){
       
        return ($a['Rates'] < $b['Rates']) ? -1 : 1;
    }

    usort($array, 'sortArray');

Uz to Rates var tik ar Foreach palīdzību.. ?

Edited by goma smile
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...