简体   繁体   中英

i want to get the value which was there in the above array

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']);
    }
}

im getting output like this:

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

But i want to prioritize based on the $ptidz value
eg:

48 berry<br>
2 apple<br>
45 lemon<br>

then you need to sort the array to priotize it.

http://php.net/manual/en/function.sort.php

Hi see this example,

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

The above example will output:

2 = apple 37 = orange 45 = lemon 98 = banana

May this help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM