开发者

Rookie PHP question sorting result of custom field

开发者 https://www.devze.com 2022-12-29 04:29 出处:网络
I use this to pull values from a custom field with several values: <?php$mykey_values = get_post_custom_values(\'services\');

I use this to pull values from a custom field with several values:

<?php  $mykey_values = get_post_custom_values('services');
    foreach ( $mykey_values as $key => $val开发者_C百科ue ) {
    echo "<li> $value</li>";
    } ?>

I want to sort the output according to the way I have set up the values in the key (alphabetically)


$mykey_values = get_post_custom_values('services');
sort($mykey_values, SORT_STRING);
echo "<ul>\n<li>" . implode('</li><li>', $mykey_values) . "</li>\n</ul>";

Documentation for get_post_custom_values() and sort().


You could use the sort() function. See it's documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号