If you look at the following code, you know that '1024*768' is within the value of $aa, but 'match' is not printed out. Why would it be like this?
$aa="Manufactory: AOC Model: spectrum 7VIr Screen Revolution: 1024*768 It's still quite new.";
$bb="1024*768";
if($po=preg_match("/$bb/i", $aa))
echo "match";
The value of $aa was retrieved from mysql which I used addslashes() before inserting into mysql in order to avoid quote or other special charators. But now it seems I got some trouble related to it.
When $bb is '7VIr Screen', it doesn't print 'match'. If $bb is 'spectrum 7VIr', then it prints 'match'. But both should print 'match' actually (This happens in my application program, not in the code above)
I guess addslashes() would add something into the original string. So when I use preg_match(), it's not matched even it appears containing the substring (the value of $bb). How to solve this problem?
Besides effect of addslashes(), I use textarea for the user input. Return charactor \n would be added into the original user input. How could I modify the code
if($po=preg_match("/$bb/i", $aa))
in order to allow it searching the substring even there is \n being added in the middle of the original user input?
Thanks.