PHPackages                             live-controls/utils - 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. live-controls/utils

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

live-controls/utils
===================

Utils package for live-controls

v1.4.13(1mo ago)02.3k—0%4PHP

Since Jul 22Pushed 1mo agoCompare

[ Source](https://github.com/live-controls/utils)[ Packagist](https://packagist.org/packages/live-controls/utils)[ RSS](/packages/live-controls-utils/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (65)Used By (4)

Utils Package for LiveControls
==============================

[](#utils-package-for-livecontrols)

[![Release Version](https://camo.githubusercontent.com/c09ba08fcd9f837535bc755414293b5b446f152f4042c948ab06c03bfd8972bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6976652d636f6e74726f6c732f7574696c73)](https://camo.githubusercontent.com/c09ba08fcd9f837535bc755414293b5b446f152f4042c948ab06c03bfd8972bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6976652d636f6e74726f6c732f7574696c73)[![Packagist Version](https://camo.githubusercontent.com/d8e4449cf161bce61fbce55cd24b53b2cd8e8ab9f15c417707ddec364b177925/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6976652d636f6e74726f6c732f7574696c733f636f6c6f723d253233303037353030)](https://camo.githubusercontent.com/d8e4449cf161bce61fbce55cd24b53b2cd8e8ab9f15c417707ddec364b177925/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6976652d636f6e74726f6c732f7574696c733f636f6c6f723d253233303037353030)

Utilities Package for LiveControls. Some of the other LiveControls packages will depend on this library.

Usage
-----

[](#usage)

### Arrays

[](#arrays)

#### array\_get

[](#array_get)

```
$array['val1' => 'Value1', 'val2' => 'Value2'];
echo array_get('val1', $array); // 'Value1'
echo array_get('val3', $array); // null
echo array_get('val3', $array, 'no_value'); // 'no_value'
```

#### array\_remove

[](#array_remove)

```
$array['val1' => 'someValue', 'val2' => 'someOtherValue'];
array_remove('val1', $array);
echo $array; //['val2' => 'someOtherValue']
```

#### array\_remove\_value

[](#array_remove_value)

```
$array ['someValue', 'someOtherValue'];
array_remove_value('someValue', $array);
echo $array; //['someOtherValue']
```

#### array\_has\_duplicates

[](#array_has_duplicates)

```
$array['someValue', 'someOtherValue'];
echo array_has_duplicates($array); //returns false
$array2['key1' => 'someValue', 'key2' => 'someValue'];
echo array_has_duplicates($array2); //returns true
$array3['1984', 1984];
echo array_has_duplicates($array3, true); //returns false, because type of value 0 is different than from value 1
$array4[1984, 1984];
echo array_has_duplicates($array4, true); //returns true, because type of value 0 and value 1 are identical
```

#### array\_get\_duplicates

[](#array_get_duplicates)

```
$array['someValue', 'someOtherValue'];
echo array_get_duplicates($array); //returns an empty array
$array2['key1' => 'someValue', 'key2' => 'someValue'];
echo array_get_duplicates($array2); //returns an array ['someValue']
$array3['1984', 1984];
echo array_get_duplicates($array3, true); //returns an empty array, because type of value 0 is different than from value 1
$array4[1984, 1984];
echo array_get_duplicates($array4, true); //returns an array [1984], because type of value 0 and value 1 are identical
```

### BBCodes

[](#bbcodes)

#### Valid bb tags

[](#valid-bb-tags)

- \[b\]\[/b\]
- \[i\]\[/i\]
- \[s\]\[/s\]
- \[u\]\[/u\]
- \[img\]\[/img\]
- \[img=varxvar\]\[/img\]
- \[center\]\[/center\]
- \[justify\]\[/justify\]
- \[right\]\[/right\]
- \[ul\]\[/ul\]
- \[ol\]\[/ol\]
- \[li\]\[/li\]
- \[url=\]\[/url\]
- \[url\]\[/url\]
- \[email=\]\[/email\]
- \[size=\]\[/size\]
- \[color=\]\[/color\]
- \[hr\]
- \[sub\]\[/sub\]
- \[sup\]\[/sup\]

### Blogging

[](#blogging)

#### estimatedReadingTime

[](#estimatedreadingtime)

Calculates the estimated reading time of a text in minutes, based on the words per minute

```
$text = "This is a text with 400 words [...]"; //Imagine this text as 400 words long
echo estimatedReadingTime($text); //Would return 2 (minutes) as the default words per minute rate is 200
echo estimatedReadingTime($text, 100); //Would return 4 (minutes) as the second parameter of the function acts as words per minute
```

### Utils

[](#utils)

#### countNumber

[](#countnumber)

Counts the amonut of numbers inside a number

```
$var = 1234;
echo countNumber($var); //'4'
```

#### calculateDaysInMonth

[](#calculatedaysinmonth)

Calculates the days between $fromDay and $toDay over a specific month

```
echo calculateDaysInMonth(0,5,11,2022); //returns the days in month as integer
```

#### number2Text

[](#number2text)

Transforms the number in cents to its textform. Needs NumberFormatter for it to work!

```
echo number2Text(100, 'pt_BR'); //returns the text representation of the number by its locale
```

#### leadingZeros

[](#leadingzeros)

Adds leading zeros to a number

```
echo leadingZeros(10, 4, false); //returns 0010
echo leadingZeros(10, 1, true); //throws exception because third parameter (isMax) is true and the number has more than 1 digit (second parameter {length})
```

#### number2Currency

[](#number2currency)

Transforms a number into its currency counterpart. Needs NumberFormatter for it to work!

```
echo number2Currency(1000.20, 'pt_br', 'USD'); //returns $1.000,20
```

#### array2String

[](#array2string)

Converts an array to string with a delimiter

```
echo array2String(['a','b','c'], '; '); //returns a; b; c
```

#### isNullOrEmpty

[](#isnullorempty)

Checks if the string is null or empty

```
echo isNullOrEmpty(' '); //returns true
```

#### calculateFormulas

[](#calculateformulas)

TODO, do not use as this is in the testing phase!

#### toInteger

[](#tointeger)

Removes all non-numeric characters and leading zeros from a string and returns an integer

```
echo toInteger('a1234'); //returns 1234
echo toInteger('a01234'); //IMPORTANT, this would also return 1234 as an integer cant start with 0. In this case use toNumeric()
```

#### toNumeric

[](#tonumeric)

Removes all non-numeric characters from a string and returns an integer or string if it starts with a 0

```
echo toNumeric('a01234'); //returns a string 01234
echo toNumeric('a1234'); //returns an integer 1234
```

#### stringContains

[](#stringcontains)

Checks if a string contains a certain needle

```
echo stringContains('Test', 'T'); //returns true
echo stringContains('Test', 'Q'); //returns false
```

#### isValidCPFCNPJ

[](#isvalidcpfcnpj)

Checks if the CPF/CNPJ number is valid

```
echo isValidCPFCNPJ('UM_CPF_OU_CNPJ_VALIDO'); //returns true if is CPF or CNPJ
```

#### isValidCPF

[](#isvalidcpf)

Checks if the CPF number is valid

```
echo isValidCPF('UM_CPF_VALIDO'); //returns true if cpf is valid
```

#### isValidCNPJ

[](#isvalidcnpj)

Checks if the CNPJ number is valid

```
echo isValidCNPJ('UM_CNPJ_VALIDO'); //returns true if cnpj is valid
```

#### toLatin

[](#tolatin)

Converts string to a string with only latin characters

```
echo toLatin('càdé'); //returns cade
```

#### importCSV

[](#importcsv)

Imports CSV from a file and returns an array with headers as first line

```
echo importCSV('test.csv'); //returns the content of the file test.csv as array with its first line as header
```

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance96

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~41 days

Total

64

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f366058ff9e06fad5c432234f0ac35a154bcc4153dbff096987489b16e87eb7?d=identicon)[daredloco](/maintainers/daredloco)

---

Top Contributors

[![daredloco](https://avatars.githubusercontent.com/u/60240491?v=4)](https://github.com/daredloco "daredloco (79 commits)")

### Embed Badge

![Health badge](/badges/live-controls-utils/health.svg)

```
[![Health](https://phpackages.com/badges/live-controls-utils/health.svg)](https://phpackages.com/packages/live-controls-utils)
```

PHPackages © 2026

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