My contemplations and diurnal novelties are publicized here


Query:-
I need to find a sub string, which is enclosed in ‘[‘ and ‘]’
e.g My String [test]
I need to get ‘test’ out of this whole string so what i did.

Solution:-

echo substr($string, strpos($string,'[‘,0) + 1, (strpos($string,’]’) – strpos($string,'[‘,0)) – 1 ) ;

Explanation:-

Substring(You string, First string position + 1, Last String Postition – First String Position – 1);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: