Hi,
I am looking for a code that can grab everything in between the brackets corresponding to a certain variable ($name).
For example, if my string is
$string =
"John{
john is a brown worm
}
Laura{
nancy is a blue pig
}";
and $name = "John", what I want returned is "john is a brown worm";
$name can equal Laura too, or any other name, in a list of n names, so John doesn't have to be the first name.
And the contents within the brackets can span multiple lines.
I am trying to do it with preg_match but it's not working.
Thanks for your help!
Extract part of a string
Moderator: General Moderators
Extract part of a string
Last edited by alste450 on Sun Oct 28, 2007 4:18 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: