sniperscope Posted January 9, 2009 Share Posted January 9, 2009 hi all, Can anyone tell me how can i split a link and assign into variable. ex. i have something like http://www.somelink.com/index.php?result=whatsoever i would like to assign this link into variable. such as $variable1 = http://www.somelink.com/index.php $variable2 = result=whatsoever here is my code and i have totally no idea how to assign them into variable. So far i can get below. $check_link = $_SERVER['HTTP_REFERER']; $divide_it = explode('?',$check_link); foreach($divide_it as $key => $value){ echo $value ."<br>"; } thanks for help Quote Link to comment https://forums.phpfreaks.com/topic/140137-solved-explode-to-variable/ Share on other sites More sharing options...
gevans Posted January 9, 2009 Share Posted January 9, 2009 $check_link = $_SERVER['HTTP_REFERER']; $divide_it = explode('?',$check_link); echo $divide_it[1]; Quote Link to comment https://forums.phpfreaks.com/topic/140137-solved-explode-to-variable/#findComment-733231 Share on other sites More sharing options...
Mark Baker Posted January 9, 2009 Share Posted January 9, 2009 take a look at the parse_url() function Quote Link to comment https://forums.phpfreaks.com/topic/140137-solved-explode-to-variable/#findComment-733232 Share on other sites More sharing options...
sniperscope Posted January 9, 2009 Author Share Posted January 9, 2009 $check_link = $_SERVER['HTTP_REFERER']; $divide_it = explode('?',$check_link); echo $divide_it[1]; Thanks a lot, gevan i solved my problem as below. $first_param = $divide_it[0]; thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/140137-solved-explode-to-variable/#findComment-733239 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.