joebudden Posted April 17, 2007 Share Posted April 17, 2007 is there any way to count the occurences of a certain character into a variable ??? $string = (1,2,3,4,5); $test = explode(",", $string); in this example there are 4 commas any help please Quote Link to comment Share on other sites More sharing options...
fert Posted April 17, 2007 Share Posted April 17, 2007 $count=0; foreach($test as $t) { if($t==',') $count++; } I'm sure there are easier ways of doing it, but what kind of php is this? $string = (1,2,3,4,5); Quote Link to comment Share on other sites More sharing options...
joebudden Posted April 17, 2007 Author Share Posted April 17, 2007 yer .. i think iv found what im looking for in the manual Quote Link to comment Share on other sites More sharing options...
joebudden Posted April 17, 2007 Author Share Posted April 17, 2007 just used this $string = "1,2,3"; $count = substr_count($string,", "); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.