View Full Version : could someone teach me how to modify a string

10-02-2012, 06:36 PM
i have a variable that looks like this

the first number could range from 1 to 33
could someone explain how to get the first value before the forward slash into a variable.
so in this case it would be '9'
but could be ''33'

10-02-2012, 06:45 PM
Google "javascript split". Split the value using / as the delimiter. The first position (position 0, not 1) will be the number you are seeking.

10-02-2012, 06:46 PM
does it have to be using js, you can do it with php really easy using explode here is the link http://php.net/manual/en/function.explode.php

im not sure really how to do this with js either but you might want to check out regex stuff i think thats what you want to use.


UPDATE: cool wolfshade i learned something today already, nice

10-02-2012, 06:49 PM
here's a simple example

function myFunc(string) {
var a = []
a= string.split('/')

10-02-2012, 07:03 PM
cheers guys just downloaded a pdf on it.
and the example worked great