...

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



c q
08-07-2002, 05:26 PM
Hii
I yeaaa it sound funny why anyone would want to do that...but some function I got requires it.
so,
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...
<?php
print($REDIRECT_URL);
print("<BR> number of slashes.. ");
print ereg("/", $REDIRECT_URL, $array);
?>
the output for. eg. is...
/cbit/template.php/
number of slashes.. 1
I thought there were three of them in this string.
Maybe I'm using the wrong function altogether.
suggestions ??

Celtboy
08-07-2002, 05:34 PM
http://us.php.net/manual/en/function.count-chars.php

firepages
08-07-2002, 06: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, 08:36 AM
yep...thanx ppl....
that substr thig worked juss perfect for me :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum