douqiao1997
2016-08-06 17:54
浏览 46
已采纳

如何将非常相似的字符串中的方差输出到数组中?

I have something like this array of strings, as seen they are very similar, with the exception of the same one place in the string:

  $strings = [
        'This is +1% better than last time!',
        'This is +2% better than last time!',
        'This is +3% better than last time!',
        'This is +4% better than last time!',
        'This is +5% better than last time!',
        ...
    ];

  // Psuedo code

From this I'd like to end up with

$array = [
    '1',
    '2',
    '3',
    '4',
    '5',
    ...
];
// And preferrably
$string = 'This is +%s% better than last time!';

Via a function that takes any array of similar strings and outputs what is actually different in them.

图片转代码服务由CSDN问答提供 功能建议

我有类似这个字符串数组的东西,看起来它们非常相似,但同一个地方除外 在字符串中:</ p>

  $ strings = [
'这比上一次好+ 1%!',
'这比上次好+ 2%!  ',
'这比上一次好3%!',
'这比上次好+ 4%!',
'这比上次好+ 5%!',
。  .. 
]; 
 
 // Psuedo code 
 </ code> </ pre> 
 
 

从此我想最终得到</ p> < pre> $ array = [ '1', '2', '3', '4', '5', ... ]; //最好是 $ string ='这比上次更好+%s%!'; </ code> </ pre>

通过一个带有任何类似字符串数组的函数 并输出实际上不同的内容。</ p> </ div>

3条回答 默认 最新

相关推荐 更多相似问题