I have been trying to get the text between two symbols to be replaced with preg_replace
, but alas still not quite getting it right as I get a null output that is empty string, this is what I have so far
$start = '["';
$end = '"]';
$msg = preg_replace('#('.$start.')(.*)('.$end.')#si', '$1 test $3', $row['body']);
So an example output I am looking for would be:
normal text [everythingheregone] after text
To
normal text [test] after text
You are defining $start and $end as arrays, but using it as normal variables. Try changing your code to this:
$start = '\[';
$end = '\]';
$msg = preg_replace('#('.$start.')(.*)('.$end.')#si', '$1 test $3', $row['body']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With