Perk
Apologies in advance <- n00b
Just ran tests > 10000 keywords
<edit> 0 > 10,000 </edit>
Up to 10000 lines array_map seems 4/5x quicker than preg_match (in this instance)? for trimming whitespace at least
<?php
$var=file_get_contents("keywords.txt");
$var=explode("\n", $var);
$new = array();
foreach ($var as $line=>$data)
{ array_push($new, $data); }
$result = array_map("randspace",$new);
function randspace($var)
{ return str_repeat(" ",rand(1,11)).$var.str_repeat(" ",rand(1,11));}
$start = microtime();
$res = array_map(trim,$new);
$finish = microtime();
echo "<br />";
echo "Array Map : ".($finish - $start);
echo "<br />";
$start = microtime();
$newArr = preg_replace('/^[\s]*(.*)[\s]*$/', '$1', $result);
$finish = microtime();
echo "Preg Match : ".($finish - $start);
?>
Array Map : 0.014735
Preg Match : 0.057089
<edit>
Original questions was fastest with non-loop - this is kind of 'loopy' unless put in method
</edit>