ThisisForReal Posted December 10, 2010 Share Posted December 10, 2010 I'm not a programmer, so sometimes the php.net/manual reads like a foreign language to me. I have a quick interpretation question: I'm generating data in PHP for a MySQL stored procedure that has two comma separated value inputs. The second input is always a series of 0's and 1's. I'm trying to count the number of 1's for the second input (in the example below, it would be "3"). Example input sent to MySQL: $query_resolve = "CALL spParticipant_Test ('188,216,342,81,117,56','0,1,1,0,0,1')"; http://www.php.net/manual/en/function.count-chars.php is mostly helpful, but I am hoping for clarification on the mode I want to run. Depending on mode count_chars() returns one of the following: 0 - an array with the byte-value as key and the frequency of every byte as value. 1 - same as 0 but only byte-values with a frequency greater than zero are listed. 2 - same as 0 but only byte-values with a frequency equal to zero are listed. 3 - a string containing all unique characters is returned. 4 - a string containing all not used characters is returned. Do I want to run mode "1"? Thanks so much for any feedback! Quote Link to comment https://forums.phpfreaks.com/topic/221214-which-mode-of-count_chars-do-i-need/ Share on other sites More sharing options...
AbraCadaver Posted December 10, 2010 Share Posted December 10, 2010 Depnds on what you're wanting. If all you want is the number of times that 1 appears then use substr_count(). Quote Link to comment https://forums.phpfreaks.com/topic/221214-which-mode-of-count_chars-do-i-need/#findComment-1145403 Share on other sites More sharing options...
ThisisForReal Posted December 10, 2010 Author Share Posted December 10, 2010 Look at that! Didn't know there was a substr_count() function. Much thanks. Quote Link to comment https://forums.phpfreaks.com/topic/221214-which-mode-of-count_chars-do-i-need/#findComment-1145412 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.