2017-09-14 47 views
0
print_r("</br>"); 
print_r($ptidz); 

foreach ($techniques as $key => $tech) 
{ 
    if (in_array($tech['tech_id'], $ptidz)) { 
     print_r("</br>"); 
     print_r($tech['tech_id']); 
     print_r($tech['tech_name']); 
    } 
} 

即時得到輸出這樣的值:我想這是有上述陣列

Array ([0] => 48 [1] => 2 [2] => 45) 
2Apple 
45lemon 
48berry 

但我想基於$ ptidz值優先
如:

48berry 
2apple 
45lemon 

回答

0

您好看到這個例子中,

<?php 
    $fruits = array("45"=>"lemon", "37"=>"orange", "98"=>"banana", "2"=>"apple"); 
    ksort($fruits); 
    foreach ($fruits as $key => $val) { 
     echo "$key = $val\n"; 
    } 
    ?> 

上例將輸出:

2 =蘋果37 =橙45 =檸檬98 =香蕉

五月這對你有幫助