In PHP, it’s pretty simple, I’d assume, array_shift($string)?
If not, I’m sure there’s some equally simple solution 🙂
However, is there any way to achieve the same thing in JavaScript?
My specific example is the pulling of window.location.hash from the address bar in order to dynamically load a specific AJAX page. If the hash was “2”, i.e. http://foo.bar.com#2…
var hash = window.location.hash; // hash would be "#2"
I’d ideally like to take the # off, so a simple 2 gets fed into the function.
Thanks!
This will take off the first character of
hashand return everything else. This is actually similar in functionality to the PHP substr function, which is probably what you should be using to get substrings of strings in PHP rather thanarray_shiftanyway (I didn’t even knowarray_shiftwould work with strings!)