How do you count the number of times a character appears in a string and execute list() that many times?
I want to split() a string like this:
/home/folder/public_html/dir1/dir2...
The backslash is the deliminator and I don't know how many subdirectories are in the path so I don't know how many occurances of the backslash there will be. So I don't know what to set the limit to and I don't know how many variables to put in the limit() function in order to capture each part of the path into a variable.
I was thinking something like this might work:
$bs_count = (# of backslashes in $path);
list($path_dirs[])=split('/',$path,$bs_count);
//output values in $path_dirs array
Not sure how to get $bs_count though and can an array be used in the list function like that?
Thanks.