对子字符串数组进行排序

编程入门 行业动态 更新时间:2024-10-25 20:26:08
本文介绍了对子字符串数组进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要订购一个包含字符串顺序的数组 名称服务器(iclsvi2或iclsvi2 o iclsvi3) 服务:ACS iclsvi2开始 服务:ALM iclsvi2开始 服务:BSOL iclsvi1开始 服务:DBAPEX iclsvi1开始 服务:DOCST iclsvi2开始 这里我需要的结果 服务:BSOL iclsvi1开始 服务:DBAPEX iclsvi1开始 服务:ACS iclsvi2启动 服务:ALM iclsvi2启动 服务:DOCST iclsvi2启动 任何人都可以帮我吗? Thx so mutch

Hi, I need to order an array contains the strings order by name server (iclsvi2 or iclsvi2 o iclsvi3) service:ACS iclsvi2 started service:ALM iclsvi2 started service:BSOL iclsvi1 started service:DBAPEX iclsvi1 started service:DOCST iclsvi2 started here the result I need service:BSOL iclsvi1 started service:DBAPEX iclsvi1 started service:ACS iclsvi2 started service:ALM iclsvi2 started service:DOCST iclsvi2 started Anyone can help me please? Thx so mutch

推荐答案

在第一个字符后抓住前7个字符空间。然后你可以用它来排序。 strpos()函数将找到第一次出现的子串的位置。用它来找到空间。 substr函数将从字符串返回子字符串。使用它来拉出空格后的7个字符。之后,您可以使用您想要使用的任何排序算法进行排序。 Grab the first 7 characters after the first space. Then you can use that to sort. The strpos() function will find the position of the first occurrence of a substring. Use that to find the space. The substr function will return a substring from a string. Use that to pull the 7 characters after the space. After that you can sort with whatever sort algorithm you want to use.

Thx Rabbit for answear但我有以下问题。 1 )我必须订购的日志报告服务之间有不同的空格:ACS和iclsvi2 2)我有很多名称服务器iclsvi2,iclsvi1还有webse02或otrweb3等等 我会知道如何命令这些不同字符串的extrac名称服务器。 在Unix中,有一个命令可以在coloumn 2而不是第1列选择字符串的一部分或者coloumn 3. 我不知道PHP语言是否可行。 有人可以帮我吗? Thx so mutch Thx Rabbit for the answear but I have these follow problem. 1) the log report I must order have different blank space between service:ACS and iclsvi2 2) I have a lot of name server iclsvi2, iclsvi1 but also webse02 or otrweb3 and so on I would know how extrac name server of these different string to order. In the Unix sheel there is a command to select a portion of string at coloumn 2 rather than column 1 or coloumn 3. I don''t know if is possible with PHP language. Anyone can help me please? Thx so mutch

你必须在一开始就提到这种东西。如果您向我们提供非代表性数据,您希望得到正确答案? 请发布包含数据中包含的不同变体的新样本数据集。只有这样,我们才能找到正确的解决方案。 You really have to mention that kind of stuff at the very beginning. How do you expect to get the right answer if you give us non-representative data? Please post a new sample dataset containing the different variations contained in your data. Only then can we work towards a correct solution.

更多推荐

对子字符串数组进行排序

本文发布于:2023-10-25 18:23:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527728.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对子   数组   字符串

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!