<?php
$fruits = array("apple","orange","papaya","grape","apple juice", "applecurd");
$content = "eaplp";
$start = microtime(true);
function sorted($s) {
$a = str_split($s);
sort($a);
return implode("", $a);
}
$pos = array_search(sorted($content), array_map("sorted", $fruits));
echo ($pos !== false) ? "$fruits[$pos] found.\n" : "not found.\n";
echo (microtime(true)-$start)*100 . "\n\n";
$fruits = array("apple","orange","papaya","grape","apple juice", "applecurd");
$content = "eaplp";
$start = microtime(true);
$content = str_split($content);
$count = count($content);
Foreach($fruits as $fruit){
$arr_fruit = str_split($fruit);
$SortCont = array_merge(array_intersect($arr_fruit, $content), array_diff($content, $arr_fruit));
If(array_slice($SortCont, 0, $count) == array_slice($arr_fruit, 0, $count)){
Echo "match: " . $fruit ."\n";
}
}
echo (microtime(true)-$start)*100;
- Output for 7.3.12
- apple found.
0.0054836273193359
match: apple
match: apple juice
match: applecurd
0.0051021575927734
- Output for 7.3.11
- apple found.
0.0052928924560547
match: apple
match: apple juice
match: applecurd
0.0046968460083008
- Output for 7.3.10
- apple found.
0.0045061111450195
match: apple
match: apple juice
match: applecurd
0.0031948089599609
- Output for 7.3.9
- apple found.
0.0056982040405273
match: apple
match: apple juice
match: applecurd
0.0059843063354492
- Output for 7.3.8
- apple found.
0.0041007995605469
match: apple
match: apple juice
match: applecurd
0.0033140182495117
- Output for 7.3.7
- apple found.
0.0036954879760742
match: apple
match: apple juice
match: applecurd
0.0026941299438477
- Output for 7.3.6
- apple found.
0.0056982040405273
match: apple
match: apple juice
match: applecurd
0.0052213668823242
- Output for 7.3.5
- apple found.
0.0034093856811523
match: apple
match: apple juice
match: applecurd
0.0030040740966797
- Output for 7.3.4
- apple found.
0.0041007995605469
match: apple
match: apple juice
match: applecurd
0.0036001205444336
- Output for 7.3.3
- apple found.
0.0054121017456055
match: apple
match: apple juice
match: applecurd
0.0043869018554688
- Output for 7.3.2
- apple found.
0.0056982040405273
match: apple
match: apple juice
match: applecurd
0.0056982040405273
- Output for 7.3.1
- apple found.
0.0044822692871094
match: apple
match: apple juice
match: applecurd
0.0041007995605469
- Output for 7.3.0
- apple found.
0.0041007995605469
match: apple
match: apple juice
match: applecurd
0.0028848648071289
- Output for 7.2.24
- apple found.
0.006103515625
match: apple
match: apple juice
match: applecurd
0.0043153762817383
- Output for 7.2.23
- apple found.
0.0047206878662109
match: apple
match: apple juice
match: applecurd
0.0053167343139648
- Output for 7.2.22
- apple found.
0.0058889389038086
match: apple
match: apple juice
match: applecurd
0.0036001205444336
- Output for 7.2.21
- apple found.
0.0046014785766602
match: apple
match: apple juice
match: applecurd
0.0031948089599609
- Output for 7.2.20
- apple found.
0.0066041946411133
match: apple
match: apple juice
match: applecurd
0.005793571472168
- Output for 7.2.19
- apple found.
0.0044107437133789
match: apple
match: apple juice
match: applecurd
0.0030994415283203
- Output for 7.2.18
- apple found.
0.005793571472168
match: apple
match: apple juice
match: applecurd
0.0040054321289062
- Output for 7.2.17
- apple found.
0.0047206878662109
match: apple
match: apple juice
match: applecurd
0.003814697265625
- Output for 7.2.16
- apple found.
0.003814697265625
match: apple
match: apple juice
match: applecurd
0.0036001205444336
- Output for 7.2.15
- apple found.
0.0072002410888672
match: apple
match: apple juice
match: applecurd
0.0053882598876953
- Output for 7.2.14
- apple found.
0.0046014785766602
match: apple
match: apple juice
match: applecurd
0.002598762512207
- Output for 7.2.13
- apple found.
0.0060081481933594
match: apple
match: apple juice
match: applecurd
0.0052928924560547
- Output for 7.2.12
- apple found.
0.0042915344238281
match: apple
match: apple juice
match: applecurd
0.002598762512207
- Output for 7.2.11
- apple found.
0.0048160552978516
match: apple
match: apple juice
match: applecurd
0.0030040740966797
- Output for 7.2.10
- apple found.
0.0055789947509766
match: apple
match: apple juice
match: applecurd
0.0072002410888672
- Output for 7.2.9
- apple found.
0.0070095062255859
match: apple
match: apple juice
match: applecurd
0.0056982040405273
- Output for 7.2.8
- apple found.
0.0056982040405273
match: apple
match: apple juice
match: applecurd
0.0059127807617188
- Output for 7.2.7
- apple found.
0.0037908554077148
match: apple
match: apple juice
match: applecurd
0.0040054321289062
- Output for 7.2.6
- apple found.
0.0055074691772461
match: apple
match: apple juice
match: applecurd
0.0043869018554688
- Output for 7.2.5
- apple found.
0.0043869018554688
match: apple
match: apple juice
match: applecurd
0.0056982040405273
- Output for 7.2.4
- apple found.
0.0043153762817383
match: apple
match: apple juice
match: applecurd
0.002598762512207
- Output for 7.2.3
- apple found.
0.006103515625
match: apple
match: apple juice
match: applecurd
0.0041961669921875
- Output for 7.2.2
- apple found.
0.0041007995605469
match: apple
match: apple juice
match: applecurd
0.002598762512207
- Output for 7.2.1
- apple found.
0.0059127807617188
match: apple
match: apple juice
match: applecurd
0.0043869018554688
- Output for 7.2.0
- apple found.
0.0059127807617188
match: apple
match: apple juice
match: applecurd
0.0039815902709961
- Output for 7.1.33
- apple found.
0.0060081481933594
match: apple
match: apple juice
match: applecurd
0.0056982040405273
- Output for 7.1.32
- apple found.
0.0047206878662109
match: apple
match: apple juice
match: applecurd
0.0031948089599609
- Output for 7.1.31
- apple found.
0.0041961669921875
match: apple
match: apple juice
match: applecurd
0.0051975250244141
- Output for 7.1.30
- apple found.
0.0060081481933594
match: apple
match: apple juice
match: applecurd
0.0051021575927734
- Output for 7.1.29
- apple found.
0.0042915344238281
match: apple
match: apple juice
match: applecurd
0.0030040740966797
- Output for 7.1.28
- apple found.
0.0037908554077148
match: apple
match: apple juice
match: applecurd
0.0046968460083008
- Output for 7.1.27
- apple found.
0.008082389831543
match: apple
match: apple juice
match: applecurd
0.0027894973754883
- Output for 7.1.26
- apple found.
0.0041007995605469
match: apple
match: apple juice
match: applecurd
0.0026941299438477
- Output for 7.1.25
- apple found.
0.0058889389038086
match: apple
match: apple juice
match: applecurd
0.0059127807617188
- Output for 7.1.24
- apple found.
0.0055074691772461
match: apple
match: apple juice
match: applecurd
0.0055074691772461
- Output for 7.1.23
- apple found.
0.0056982040405273
match: apple
match: apple juice
match: applecurd
0.0037908554077148
- Output for 7.1.22
- apple found.
0.007319450378418
match: apple
match: apple juice
match: applecurd
0.0085115432739258
- Output for 7.1.21
- apple found.
0.0049829483032227
match: apple
match: apple juice
match: applecurd
0.0040054321289062
- Output for 7.1.20
- apple found.
0.0059127807617188
match: apple
match: apple juice
match: applecurd
0.0044107437133789
- Output for 7.1.19
- apple found.
0.0039100646972656
match: apple
match: apple juice
match: applecurd
0.002598762512207
- Output for 7.1.18
- apple found.
0.0051975250244141
match: apple
match: apple juice
match: applecurd
0.0049114227294922
- Output for 7.1.17
- apple found.
0.0046014785766602
match: apple
match: apple juice
match: applecurd
0.0041007995605469
- Output for 7.1.16
- apple found.
0.0065803527832031
match: apple
match: apple juice
match: applecurd
0.0051021575927734
- Output for 7.1.15
- apple found.
0.0074148178100586
match: apple
match: apple juice
match: applecurd
0.0060081481933594
- Output for 7.1.14
- apple found.
0.0090122222900391
match: apple
match: apple juice
match: applecurd
0.0080108642578125
- Output for 7.1.13
- apple found.
0.0055074691772461
match: apple
match: apple juice
match: applecurd
0.0049829483032227
- Output for 7.1.12
- apple found.
0.0066995620727539
match: apple
match: apple juice
match: applecurd
0.0054836273193359
- Output for 7.1.11
- apple found.
0.0056028366088867
match: apple
match: apple juice
match: applecurd
0.0049829483032227
- Output for 7.1.10
- apple found.
0.0060081481933594
match: apple
match: apple juice
match: applecurd
0.0046968460083008
- Output for 7.1.9
- apple found.
0.0039100646972656
match: apple
match: apple juice
match: applecurd
0.0030994415283203
- Output for 7.1.8
- apple found.
0.0050067901611328
match: apple
match: apple juice
match: applecurd
0.0053882598876953
- Output for 7.1.7
- apple found.
0.0046014785766602
match: apple
match: apple juice
match: applecurd
1.7723798751831
- Output for 7.1.6
- apple found.
0.006103515625
match: apple
match: apple juice
match: applecurd
0.0065088272094727
- Output for 7.1.5
- apple found.
0.0062942504882812
match: apple
match: apple juice
match: applecurd
0.0045061111450195
- Output for 7.1.4
- apple found.
0.0054121017456055
match: apple
match: apple juice
match: applecurd
0.0042915344238281
- Output for 7.1.3
- apple found.
0.0056028366088867
match: apple
match: apple juice
match: applecurd
0.0045061111450195
- Output for 7.1.2
- apple found.
0.47328472137451
match: apple
match: apple juice
match: applecurd
0.005793571472168
- Output for 7.1.1
- apple found.
0.0043869018554688
match: apple
match: apple juice
match: applecurd
0.0027179718017578
- Output for 7.1.0
- apple found.
0.0045061111450195
match: apple
match: apple juice
match: applecurd
0.0044107437133789
- Output for 7.0.33
- apple found.
0.0050067901611328
match: apple
match: apple juice
match: applecurd
0.0037908554077148
- Output for 5.6.38
- apple found.
0.0077962875366211
match: apple
match: apple juice
match: applecurd
0.010395050048828
preferences:
116.16 ms | 401 KiB | 79 Q