Jump to content

Fetching last characters after "=" sign


Recommended Posts

Hi all

 

I want to fetch last characters after........... "=" sign .......

 

http://www.abc.com/index.php?site=new

 

I want to fatch only........ new

 

 

http://www.abc.com/i...p?site=previous

 

I want to fatch only........ previous

 

 

 

Thanks

http://www.idea-ads.com

Link to comment
https://forums.phpfreaks.com/topic/281348-fetching-last-characters-after-sign/
Share on other sites

One thread for a question. Just one thread. Don't need to post three of them in different forums.

 

So you're in the index.php script and want to get the "new" from the URL? $_GET

echo $_GET["site"];
If you're not sure the "site=next" is even present in the URL, which it might not be, then use isset to check if it is before you try to use it.

if (isset($_GET["site"])) {
	$site = $_GET["site"];
	// ...
} else {
	// wasn't given
}

One thread for a question. Just one thread. Don't need to post three of them in different forums.

 

So you're in the index.php script and want to get the "new" from the URL? $_GET

echo $_GET["site"];
If you're not sure the "site=next" is even present in the URL, which it might not be, then use isset to check if it is before you try to use it.

if (isset($_GET["site"])) {
	$site = $_GET["site"];
	// ...
} else {
	// wasn't given
}

No no, actually, http://www.abc.com/index.php?site=new ... is a single string, i want to explode this... I want to devide this in two parts... breaking through "=" sign

Or, if you ONLY need the text after the equal sign and don't need the part before, you can use strpos() and substr()

 

$value = substr($input, strpos($input, '='));

 

Although, you could also just use strrchr(), but that would include the equal sign in the result and require another step as well.

Or, if you ONLY need the text after the equal sign and don't need the part before, you can use strpos() and substr()

$value = substr($input, strpos($input, '='));

Although, you could also just use strrchr(), but that would include the equal sign in the result and require another step as well.

this includes "=" sign, which i don't want

 

anyway many thanks for your answer

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.