I'm trying to count the number of times a certain value turns up in an array. Except this value will always increment by 1, and there is an unknown number of these values in the array.
Example:
$first = array( 'my-value-1','my-value-2','my-value-3' );
$second = array( 'my-value-1','my-value-2','my-value-3', 'my-value-4', 'my-value-5' );
My goal is to be able to retrieve a count of 3 for $first and a count of 5 for $second in the example above.
There may be other values in the array, but the only values I'm interested in counting are the ones that start with my-value-.
I won't know the number of the values in the array, but they will always start with my-value- with a number added to the end.
Is there a way to count the number of times my-value- shows up in the array with some sort of wildcard?
count($arrayname)give you how many occurances there are in an arraymy-value-then it would have been useful to show that in the samples you provide