How can I use a regular expression in the substr()
PHP function to get a substring matched by a pattern?
Edited:
example:
$name = 'hello [*kitty*],how good is today';
I want to get what is between [....] placeholder.
How can I use a regular expression in the substr()
PHP function to get a substring matched by a pattern?
Edited:
example:
$name = 'hello [*kitty*],how good is today';
I want to get what is between [....] placeholder.
substr()
only matches whole strings. You are looking forpreg_match()
.Update:
You can find the name in
$match[1]
. I suggest you read up on regular expressions to understandpreg_match()
.Try this:
Oops, fixed it now :)