I've been trying to find a solution for this, but my search has been unsuccessful.
I'd like to find a PHP function which counts the number of forward slashes ("/") in a string.
Example 1: The string "var/public_html/website/index.php" should return 3.
Example 2: The string "directory/subdirectory" should return 1.
It seems easy, but I haven't been able to find anything that does this.