How can I sort the values in descending order? I've tried arsort(); but it doesn't work in my case:
$text1 = 'Android SDK, application, familiar with MVP architecture, android studio, angular, angular js';
$skill = array("android sdk"=>"3", "application"=>"1", "angular"=>"2", "android studio"=>"3", "angular js"=>"3");
foreach ($skill as $skills => $weight) {
if (preg_match_all("~$skills~i", $text1, $matchWords)) {
$matchWords = $matchWords[0];
$matchWords = array_unique($matchWords);
}
$text2 = 'Native Android development';
// Filter $words, keep only the items that are not present in $text2
$missing = array_filter(
$matchWords,
function($w) use ($text2) {
// return TRUE when $w is not in $text
return preg_match('/'.preg_quote($w, '/').'/i', $text2) == 0;
});
$weight = array($weight);
$dev = array_combine($missing, $weight);
arsort($dev);
foreach($dev as $x => $x_value)
echo "Key: " . $x . " Value: " . $x_value;
echo "<br>";
}
Output:
Key: Android SDK Value: 3
Key: application Value: 1
Key: angular Value: 2
Key: android studio Value: 3
Key: angular js Value: 3
But I'd like to get this result:
Key: Android SDK Value: 3
Key: android studio Value: 3
Key: angular js Value: 3
Key: angular Value: 2
Key: application Value: 1
EDIT:
I haven't found an answer here as suggested.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…