I think this is a carriage return problem (or related), but I just can't seem to fix it.

I have a <textarea> box into which I input and upload lists of products. It works. (Or seems to work until I try to search for and retrieve specific products).

$list_items is my array, which I split out and add each item to it's own MySQL database field, one for each item. ie

PHP Code:
$listitems explode("\n"$list_items);
                        
while (list(
$list_item) = each ($listitems)) {

add_list_items($list_item);


Trouble is, when I come to search for an item, I fail, except in two specific instances:

First, my search function (not shown here) works when I overwrite the items directly in my MySQL database (phpMyAdmin). It successfully retrieves an item.

The second (and the reason I think it may be a carriage return problem) instance when my search function works is when I search for an item which I know was the last item of an uploaded list. ie if I've uploaded a list of three products, when searching for the third item, my function will retrieve it, (no carriage return in it?), but not the first two.

(Not that I can see any carriage returns in my database fields by the way.)

I've tried adding the following into the routine above before anything is added to my database, but it's made no difference.

PHP Code:
$list_item str_replace("\r\n"""$list_item); 
And now I'm out of ideas. (Software running on LAMP)

Simon