Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    c q
    c q is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if I wanna count the number of slashes in a url ??

    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 ??

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,093
    Thanks
    11
    Thanked 101 Times in 99 Posts
    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
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    c q
    c q is offline
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanxxxx

    yep...thanx ppl....
    that substr thig worked juss perfect for me


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •