PHPackages                             manuwhat/avc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. manuwhat/avc

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

manuwhat/avc
============

avc - extends PHP array\_count\_values native function to count any PHP type value in iterable variables

04

Since May 15Compare

[ Source](https://github.com/manuwhat/AVC)[ Packagist](https://packagist.org/packages/manuwhat/avc)[ RSS](/packages/manuwhat-avc/feed)WikiDiscussions Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

AVC
===

[](#avc)

[![Build Status](https://camo.githubusercontent.com/7da9495d70fb85f8c7505aa268b31a6741fe331bc2a1d0b4efc48d5107512d6a/68747470733a2f2f7472617669732d63692e6f72672f6d616e75776861742f4156432e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/manuwhat/AVC)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0a11cfc3fe8b17e96400b242fcceeb7165e9fa3c89cfdbc304a617745ae5d747/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616e75776861742f4156432f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/manuwhat/AVC/?branch=master)[![Build Status](https://camo.githubusercontent.com/c92e4f9f352ad1f0e71756b0c0a83e39a41212d2811e2079d77ac90fec574e48/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616e75776861742f4156432f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/manuwhat/AVC/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/5bc65eebe81f62e521de5d52d08e9cf0ee38f3907b527b0631e5a509b9853cd0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616e75776861742f4156432f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)

Extends PHP array\_count\_values native function to count any PHP type value in iterable variables

**Requires**: PHP 5.3+

### Why use this instead of native PHP array\_count\_values function?

[](#why-use-this-instead-of-native-php-array_count_values-function)

Typically you would use it:

1. You need to count values not only in arrays but also in iterator ,generator.
2. You want to count values of other types than integer and string. .

### How to use it

[](#how-to-use-it)

Require the library by issuing this command:

```
composer require manuwhat/avc
```

Add `require 'vendor/autoload.php';` to the top of your script.

```
require 'AVC.php';//require helpers file

var_dump(count_values(array_merge(range(0, 5), array(array()), array(array()), array(array(6)))));

/* output
array(8) {
  [0]=>
  array(2) {
    [0]=>
    int(0)
    [1]=>
    int(1)
  }
  [1]=>
  array(2) {
    [0]=>
    int(1)
    [1]=>
    int(1)
  }
  [2]=>
  array(2) {
    [0]=>
    int(2)
    [1]=>
    int(1)
  }
  [3]=>
  array(2) {
    [0]=>
    int(3)
    [1]=>
    int(1)
  }
  [4]=>
  array(2) {
    [0]=>
    int(4)
    [1]=>
    int(1)
  }
  [5]=>
  array(2) {
    [0]=>
    int(5)
    [1]=>
    int(1)
  }
  [6]=>
  array(2) {
    [0]=>
    array(0) {
    }
    [1]=>
    int(2)
  }
  [7]=>
  array(2) {
    [0]=>
    array(1) {
      [0]=>
      int(6)
    }
    [1]=>
    int(1)
  }
}

*/
```

AS you may see the result is a multi-dimensional array and this is great but not very convenient. So the package provide an iterator to easily handle the result.One can use it this way:

```
require 'AVC.php';//require helpers file

$x=count_values(array_merge(range(0, 5), array(array()), array(array()), array(array(6))),true);

foreach ($x as $value=>$count){
	if(is_array($value)||is_object($value)){
		var_dump($value);
	}elseif(is_resource($value)){
		var_dump(stream_get_meta_data ($value));
	}else{
		echo "$value=>$count";
	}

}
```

When the handled variable doesn't contain type other than integer or string the function return exactly the same output as the native array\_count\_values function except if an iterator have been required.

Note that when the handled variable contain types other than integer and string and an iterator has been required as result, you can access the count using array access syntax .For example:

```
require 'AVC.php';//require helpers file

$x=count_values(array_merge(range(0, 5), array(array()), array(array()), array(array(6))),true);

echo $x[array()];
/*
output:
2
*/
```

3 helpers are provided in the AVC.php file

count\_values,value\_count,count\_diff\_values

To run unit tests

```
phpunit  ./tests
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29569475?v=4)[Akpé Aurelle Emmanuel Moïse Zinsou](/maintainers/manuwhat)[@manuwhat](https://github.com/manuwhat)

### Embed Badge

![Health badge](/badges/manuwhat-avc/health.svg)

```
[![Health](https://phpackages.com/badges/manuwhat-avc/health.svg)](https://phpackages.com/packages/manuwhat-avc)
```

###  Alternatives

[mdixon18/fontawesome

A FontAwesome Nova field.

15200.3k](/packages/mdixon18-fontawesome)[faonni/module-sales-sequence

Extension change format IncrementID for orders, invoices, creditmemos and shipments.

1318.7k](/packages/faonni-module-sales-sequence)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
