php xpath 按字段字母顺序排序
我想要对 xpath 进行更准确的字母排序。我当前的系统仅对字段的前两个字符进行排序...如果可能的话,我希望对整个字段进行排序。
foreach(range('A','Z') AS $firstletter) {
foreach(range('a','z') AS $secondletter) {
$letters = $firstletter.$secondletter;
if($item->xpath("/Entries
/Entry[
starts-with(
Field42,
'".$letters."'
)
and
Field380 = 'Okay'
]")) {
Field42 条目是姓氏(即 Brown、Brownstein、Brownwood、Byrnes 等)
I'd like to have a more accurate alphabetical sort for xpath. My current system only sorts the first two characters of the field... I'd like it the order the whole field if possible.
foreach(range('A','Z') AS $firstletter) {
foreach(range('a','z') AS $secondletter) {
$letters = $firstletter.$secondletter;
if($item->xpath("/Entries
/Entry[
starts-with(
Field42,
'".$letters."'
)
and
Field380 = 'Okay'
]")) {
The Field42 entries are lastnames (ie Brown, Brownstein, Brownwood, Byrnes,..)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您无法使用 XPath 进行排序(其目标是选择数据,而不是对其进行排序)。
那么,为什么不在纯 PHP 中执行此操作:
sort
、asort
,usort
,...I don't think you'll be able to sort using XPath (its goal being to select data -- not sort it).
So, why not do it in pure-PHP :
sort
,asort
,usort
, ...