Hi,
I have a problem with searching for strings within strings. What I have is a session variable called $basketContents.
Now every time a new item is selected it is in this format:
ID,Title,QTY,Price:
e.g.
1,Matrix,1,20.99:
Then when another item is selected it is added to the end of this string.
e.g.
1,Matrix,1,20.99:4,Meet The Parents,1,16.99:
So I know that the sysmbol ":", differenciates each item.
Only problem is if an item is selected for a second time, then instead of re-entering it into the session string it would be better to change the QTY to 2.
So I have been trying to use:
$qty = substr_count($ckBasketContents, $basketContents);
Where $ckBasketContents is the item selected and $basketContents is the session variable containing all my items.
However this does not seem to be working as if I use this code:
$qty = substr_count($ckBasketContents, $basketContents);
if ($qty>1){
echo "Found more than once";
}else{
echo "Only occurs once";
}
And add two instances of the same title, it does not bring back a value greater than 1. So it is obviously not recognising that the string $basketContents contains two instances of a particular string (in this case a title name, e.g. Matrix).
Can anyone tell me how I can check to see if there is more than one instance within my session string.
Thanks for any help
Regards
Gary