Returns count / amount of elements that are not array

@param array $array The array to count
@return null|int
500539
public static function getNonArrayElementsCount(array $array)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $count = 0;

        foreach ($array as &$value) {
            if (is_array($value)) {
                $count += self::getNonArrayElementsCount($value);

                continue;
            }

            ++$count;
        }

        return $count;
    }
1113691
public static function havingComplete($array){
        $c = 0;
        $r = "";
        if( is_array( $array ) )
            foreach($array as $k => $v){
                if($c) $r .= " AND ";

                if (strpos($v, ":") !== false){ // number range [0] e [1]
                    $vArray = explode(":",$v);
                    if($vArray[0] <= $vArray[1])
                        $r .="(" .$k ." BETWEEN ".$vArray[0]." AND ".$vArray[1].")";
                }else{
                    if (strpos($v, ">") !== false){ // number [0] bigger than [1]
                        $v = str_replace(">", "", $v);
                        $r .= $k ." >".$v."";
                    }else if (strpos($v, "<") !== false){ // number [1] bigger than [0]
                        $v = str_replace("<", "", $v);
                        $r .= $k ." <".$v."";
                    }else{ // number only
                        $r .= $k ." = ".$v."";
                    }
                }

                $c++;
            }
        return empty($r) ? "1=1" : $r;
    }
934334
public function getArrayLevel($array)
	{
		$n=1;
		foreach ($array as $item) {
			if(is_array($item)){
				$n=$this->getArrayLevel($item)+1;
			}
		}
		return $n;

	}
148287
public function parseArrayToEntity($array)
    {
        $element = new CatalogElement();
        $element->set($array);

        if (isset($array['custom_fields'])) {
            foreach ($array['custom_fields'] as $customFieldArray) {
                $customField = new CustomField($customFieldArray['id']);
                $customField->set($customFieldArray);

                if (isset($customFieldArray['values'])) {
                    foreach ($customFieldArray['values'] as $value) {
                        $value = new Value($value);
                        $customField->addValue($value);
                    }
                }

                $element->addCustomField($customField);
            }
        }

        return $element;
    }
144327
public static function getRectangularDimensions(array $array)
    {
        $return = -1;
        $allArrays = array_map('is_array', $array);
        // all elements are arrays, iterate through them and call the static function recursively
        if (self::allElementsEqual($allArrays, true)) {
            $elementsPerArray = array();
            foreach ($array as $row) {
                $noElements = self::getRectangularDimensions($row);
                if ($noElements == -1) {
                    return $noElements;
                }
                $elementsPerArray[] = $noElements;
            }
            if (!self::allElementsEqual($elementsPerArray)) {
                return -1;
            } else {
                $return   = reset($elementsPerArray);
                $return[] = count($elementsPerArray);
            }
        } // none of the elements are arrays, return number of elements of the "bottom" array
        elseif (self::allElementsEqual($allArrays, false)) {
            $return = array(0 => count($array));
        }

        return $return;
    }
1044943
public function listify($array)
    {
        $sep      = $this->getMessage('Item separator');
        $sep_last = $this->getMessage('Item separator last');
        $ret = '';
        for ($i = 0, $c = count($array); $i < $c; $i++) {
            if ($i == 0) {
            } elseif ($i + 1 < $c) {
                $ret .= $sep;
            } else {
                $ret .= $sep_last;
            }
            $ret .= $array[$i];
        }
        return $ret;
    }
264107
public function writeArray(&$array)
    {
        $length = count($array);
        if (!$length < 0) {
            // write the length of the array
            $this->_stream->writeLong(0);
        } else {
            // Write the length of the numeric array
            $this->_stream->writeLong($length);
            for ($i=0; $i<$length; $i++) {
                $value = isset($array[$i]) ? $array[$i] : null;
                $this->writeTypeMarker($value);
            }
        }
        return $this;
    }
802175
function arrayFilterEmpty($array)
    {
        $rest = array_filter($array);
        if (empty($rest)) {

            return true;
        }

        foreach ($rest as $key => $value) {
            if ( ! is_array($value) && ! empty($value)) {
                return false;
            }

            if (is_array($value)) {
                if (empty(array_filter($value))) {
                    $rest[$key] = true;
                } else {
                    $rest[$key] = $this->arrayFilterEmpty($value);
                }
            } else {
                $rest[$key] = false;
            }
        }

        return ! in_array(false, $rest);
    }
1044584
public static function trimRecursive(array $array)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return [];
        }

        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[$key] = self::trimRecursive($value);

                continue;
            }

            if (is_string($value)) {
                $value = trim($value);
            }

            $result[$key] = $value;
        }

        return $result;
    }
1202503
public static function depth(array $array) : int
    {
        $maxDepth = 1;

        foreach ($array as $value) {
            if (is_array($value)) {
                $depth = self::depth($value) + 1;

                if ($depth > $maxDepth) {
                    $maxDepth = $depth;
                }
            }
        }

        return $maxDepth;
    }
317802
private function _arrayShiftAssoc(array &$array)
    {
        if (empty($array)) {
            return null;
        }
        
        // Make sure that the array variable is pointing to the beginning of the array
        reset($array);
        
        // Now, get the first key and first value
        $firstKey   = key($array);
        $firstValue = current($array); // equivalent to $array[$firstKey]
        
        unset($array[$firstKey]);
        
        return [$firstKey, $firstValue];
    }
732047
private static int countElementOccurrence(Object element, Object[] array) {

        int count = 0;
        for ( int i= 0; i < array.length; ++i ) {
            Object arrayElement = array[i];
            if (arrayElement != null && element != null) {
                if (arrayElement.equals(element)) {
                    count ++;
                }
            }
        }    
        return count;

    }
798954
public static function tabSum($array)
    {
        $res = $array[0];

        for ($i = 0; $i < count($array); $i++) {
            if($i % 2)
                $res = $array[$i] + $res;
        }

        return $res;
    }
351467
public static function removeEmptyElementsRecursively(array $array): array
    {
        $result = $array;
        foreach ($result as $key => $value) {
            if (is_array($value)) {
                $result[$key] = self::removeEmptyElementsRecursively($value);
                if ($result[$key] === []) {
                    unset($result[$key]);
                }
            } elseif ($value === null) {
                unset($result[$key]);
            }
        }
        return $result;
    }
532348
protected function get(array $array, $key)
    {
        if (isset($array[$key])) {
            return $array[$key];
        }

        foreach (explode(".", $key) as $part) {
            if (!is_array($array) or !isset($array[$part])) {
                return null;
            }

            $array = $array[$part];
        }

        return $array;
    }
724820
public function mergeArray(array $array = null)
    {
        $count = 0;

        if (is_array($array)) {
            if (count($array) > 0) {
                foreach ($array as $key => $item) {
                    if (!$this->containsKey($key)) {
                        $this->addItem($item);
                        $count++;
                    }
                }
            }
        } elseif ($array !== null) {
            throw new ENabuCoreException(
                ENabuCoreException::ERROR_METHOD_PARAMETER_NOT_VALID,
                array('$array', print_r($array, true))
            );
        }

        return $count;
    }
751594
private function calculate2(array $array)
    {
        for ($i=0; $i<count($array); $i++) {
            if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1])
            && ($array[$i] === '*' || $array[$i] === '/')) {
                $this->checkInf($array[$i-1], $array[$i+1]);
                if (!is_numeric($array[$i-1]) || !is_numeric($array[$i+1])) {
                    $this->correct = 0;
                    break;
                }
                if ($array[$i] === '*') {
                    $a = $array[$i-1] * $array[$i+1];
                } elseif ($array[$i] === '/') {
                    if ($array[$i+1] != 0) {
                        $a = $array[$i-1] / $array[$i+1];
                    } elseif ($array[$i-1] != 0 && $array[$i+1] == 0) {
                        $a = ($array[$i-1] > 0) ? INF : -INF;
                    } else {
                        $a = NAN;
                    }
                }
                unset($array[$i-1], $array[$i+1]);
                $array[$i] = $a;
                $array = array_values($array);
                $i = 0;
            }
        }
        return $array;
    }