View Full Version : if I wanna count the number of slashes in a url ??

c q
08-07-2002, 06:26 PM
I yeaaa it sound funny why anyone would want to do that...but some function I got requires it.
how can I count the number of times a particular characher occurs in a given string ?
I tried using preg_match, and ereg, but they work only if the character repeats itself as in aaaaa, but not as in asacaval
well, here's my code...
print("<BR> number of slashes.. ");
print ereg("/", $REDIRECT_URL, $array);
the output for. eg. is...
number of slashes.. 1
I thought there were three of them in this string.
Maybe I'm using the wrong function altogether.
suggestions ??

08-07-2002, 06:34 PM

08-07-2002, 07:22 PM
Hey Celt ! - (assuming thats you) - thats a handy function which I gotta be honest and say I had never spotted before aggg the time that would have saved :)

c q
08-08-2002, 09:36 AM
yep...thanx ppl....
that substr thig worked juss perfect for me :D