Hi Im trying to concatinate a string before converting that string into regex in PHP, but the problem is it's not displaying as expected. I've been searching using google and found out about preg_quote, problem is it's not working well.
Here is my example:
$mystring = "banana"; // put this to a variable assume this value is dynamic
$regex_str = "/^"$mystring"\-[a-z0-9]\-[a-z0-9]$/";
//Im expecting expecting /^banana\-[a-z0-9]\-[a-z0-9]$/
$regex = preg_quote($regex_str);
but what I am getting is:
/\^banana\\\-\[a\-z0\-9\]\\\-\[a\-z0\-9\]\$/
and always returning the wrong value.