Hi all, hope you are having a better day than I am...

I am trying to write the results of a search of text using preg_match_all to a database...

First thing I need to do is write the results of the search to an array (which preg_match_all does)... It writes the results to a two dimensional array... WHICH IS GOOD...

However I am struggling to return the results in that array (ie the returned values, not the keys), but with zero luck - WHICH IS BAD...

below is the code that I am using, but does not seem to want to work...

foreach($foundKeywords as $value)
    echo "Keyword:$value?\n";

Any ideas as to what I am doing wrong?

Thanks in advance...

Member Avatar

We'd have a better idea if you tried to explain what you hope to achieve from the regex pattern and an example of text help in the $tDescrip variable. For example does the var contain multilines (i.e \n)?

Thanks diafol

Intent is to capture any words that start with a hashtag (#) and write them as seperate records in a database... The var will have multilines...

Hope this helps...


Member Avatar

The s modifier may be overkill, but this seems to work for me:

$txt = "#me #prob #see #lemon
#hello #free";



Thanks diafol managed to sort it out... User input error on my part (no suprise there) ;-)

thanks again

Member Avatar

Ok solved?

yep and marked accordingly