sorting arrays posts

Code Snippet to Find the Number of a Certain Value in an Array (PHP)

I recently developed an application that sent variables into a mathematic function. This function needed to have a numeric count of the exactly how many zeros there were in a certain array. For this snippet, we can use both numeric and text based arrays. I printed it using this code: Our two example arrays will be: $array_num = array(1, 1, 1, 2, 3, 4, 4, 4, 4, 4, 5, 6); $array_text = array(apple, apple, apple, orange, banana, banana); We then put this array into array_count_values() $count_array_num =...
read more

PHP Arrays: Defining, Looping and Sorting Simple Arrays

Unlike scalar variables, which assign only a single value to a variable, an array variable can hold multiple values. Arrays are useful for holding values from database queries or web form entries, where each field (also called a “key”) holds a specific value. Let's take a look at how we define some of the arrays we use in PHP.Numbered Arrays. If the programmer does not specify a key for each value in the array, PHP automatically numbers the keys, starting from zero. This code defines an array $arrMonths[],...
read more