Hi I need to take the number off of the end of a url and do some processing with it. so for example: www.something.com/something/10001 i will need to seperate them into 2 different variables, for example: $var1 = www.something.com/something/ $var2 = 10001 is this possible? Thanks
Since this is the PHP forum $array = explode('/', $url); //split the pieces $count = count($array); //find out how many there are $var2 = $array($count - 1); //the last one is the number unset($array[$count - 1]); //get rid of the number $var1 = implode('/', $array); //the remaining array holds the URL PHP: (This is untested code, so use it as a starting point.)
<?php $url = "www.something.com/something/10001"; $exp = explode("/", $url); $num_len = strlen($exp[count($exp)-1]); $url_len = strlen($url)-$num_len; $var1 = substr($url, 0, $url_len); $var2 = substr($url, $url_len, $num_len); ?> Code (markup): Tested and working