Hello,
How to get a specific string from a variable
Like this;
There are 3 variables;
$var1 = "http://www.google.lk/setprefs?sig=[b]1_ ... lZSjtrMzck[/b]=abcdef&id=000001"
$var2 = "http://www.google.lk/setprefs?sig=[b]2_ ... WpWjtrMzck[/b]=abcdef&id=000001"
$var3 = "http://www.google.lk/setprefs?sig=[b]3_ ... lZSjtrMzck[/b]=abcdef&id=000001"
How to extract that bold letters from the above variables (var1,var2 and var3)
note that bold letters part is varied.
http://www.google.lk/setprefs?sig=<varied>=abcdef&id=000001
- red colored part are fixed.
So how to get the varied part of string (in blue) to a variable.
That is i want to get the string part between
http://www.google.lk/setprefs?sig= AND =abcdef&id=000001
need help
Thanks
Extracting a part of a String
Moderator: General Moderators
-
cavemaneca
- Forum Commoner
- Posts: 59
- Joined: Sat Dec 13, 2008 2:16 am
Re: Extracting a part of a String
With This the bold would be left.
Also, don't post a new topic just because you don't get an answer you like.
Code: Select all
$string = "http://www.google.lk/setprefs?sig=1_7I4o546645646ZZZZXXRRRKFNM9lZSjtrMzck=abcdef&id=000001";
$string = str_ireplace ('http://www.google.lk/setprefs?sig=','',$string);
$string = str_ireplace ('=abcdef&id=000001','',$string);