Hello,
I want to count the number of times "/" appears in this url
Here is my code
$url = "http://www.google.com/images/srpr/nav_logo14.png";
$url_arr = eregi(".",$url);
echo count($url_arr);
It displays on "1"
Appreciate all help
Thanks Jean
Hello,
I want to count the number of times "/" appears in this url
Here is my code
$url = "http://www.google.com/images/srpr/nav_logo14.png";
$url_arr = eregi(".",$url);
echo count($url_arr);
It displays on "1"
Appreciate all help
Thanks Jean
You could use explode() and count():
$url = "http://www.google.com/images/srpr/nav_logo14.png";
$url_arr = explode(".", $url);
echo count($url_arr);
The reason eregi() returns 1 is that eregi() returns the length of the matched string.
echo substr_count($url, '/');
See the documentation for more information.