suppose i have a set of strings formatted in a way:
$string1 = "(substring1) Hello";
$string2 = "(substring2) Hi";
how do i get the inside of '()' as a single string. I know this is possible by using:
$substring = explode( ")",$string1 );
but then i'm left with $substring[0] containing "(substring", and $substring[1] containing the rest. Is there a fast wat to get the inside of '()'? thanks i know it's a no brainer question.
explodeis used when you want to split a string into multiple parts. What you want here is to extract one string from another string according to a certain pattern. Thuspreg_match(_all)is the way to go. Hanky Panky's answer is exactly how I would have solved this.