Welcome Guest, Not a member yet? Register   Sign In
match items in an array against text
#1

[eluser]matt2012[/eluser]
Ok so I have a large array and a large text to search my aim to create a new array based on what items in the large array are found in the text

so something like
Code:
$myarray = array("apple juice","nice cake","ice cream",...)

$my text = "I like apple juice and ice cream"

foreach ($myarray as $item):
  $x = strpos($mytext, $item);
  if (strpos !== 0) $newarray[] = $item;
endforeach;

given that its a large array and large text this seems inefficient is their a better way to tackle this?


Messages In This Thread
match items in an array against text - by El Forum - 04-14-2009, 02:57 AM
match items in an array against text - by El Forum - 04-14-2009, 03:10 AM
match items in an array against text - by El Forum - 04-14-2009, 03:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB