PHPackages                             michabbb/ejz-core - 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. michabbb/ejz-core

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

michabbb/ejz-core
=================

Set of help functions. Added to global scope.

066PHP

Since Aug 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/michabbb/ejz-core)[ Packagist](https://packagist.org/packages/michabbb/ejz-core)[ RSS](/packages/michabbb-ejz-core/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Core
====

[](#core)

Core is a set of help functions. Added to global scope.

### Install

[](#install)

```
$ mkdir myproject && cd myproject
$ curl -sS 'https://getcomposer.org/installer' | php
$ php composer.phar require michabbb/ejz-core:~1.0
```

To use it, just include `vendor/autoload.php` in your script.

### Requirements

[](#requirements)

PHP 5.5 or above (with cURL and GD library installed).

### Functions

[](#functions)

Each function is added to global scope. You shouldn't include any namespace.

### esc

[](#esc)

---

Encode basic HTML chars: `>`, ` HTML: &lt;&gt;&amp;
$s = esc($s, $decode = true);
// $s => HTML: &
```

### fesc

[](#fesc)

---

Encode HTML chars: `>`, ` HTML: &lt;&gt;&amp;, &#039;&quot;
$s = fesc($s, $decode = true);
// $s => HTML: &, '"
```

### cloakHTML

[](#cloakhtml)

---

Hide some sensitive value in HTML.

##### *Arguments:*

[](#arguments-2)

- *s:* string to work with

##### *Examples:*

[](#examples-2)

```
$value = cloakHTML("value");
echo
END;
// =>
```

### str\_truncate

[](#str_truncate)

---

Truncate long string.

##### *Arguments:*

[](#arguments-3)

- *string:* goes without saying
- *len:* maximum length (`40`)
- *center:* show tail or not (`true`)
- *replacer:* string that replaces missing part (`...`)

##### *Examples:*

[](#examples-3)

```
$s = str_truncate("Hello, world!", 5);
// $s => H...!
$s = str_truncate("Hello, world!", 5, $center = false, '..');
// $s => Hel..
```

### mt\_shuffle

[](#mt_shuffle)

---

Shuffles array using `mt_rand()` function.

##### *Arguments:*

[](#arguments-4)

- *items:* reference to an array
- *seed:* seed for shuffling algorithm (`null`)

##### *Examples:*

[](#examples-4)

```
$a = array(1, 2, 3, 4, 5);
array_shuffle($a);
// $a => [3, 1, 5, 4, 2]
```

### file\_get\_ext

[](#file_get_ext)

---

Get extension from filename.

##### *Arguments:*

[](#arguments-5)

- *file:* filename

##### *Examples:*

[](#examples-5)

```
$ext = file_get_ext("/etc/passwd");
// $ext => ""
$ext = file_get_ext("/etc/nginx/nginx.conf");
// $ext => conf
```

### file\_get\_name

[](#file_get_name)

---

Get name without extension from filename.

##### *Arguments:*

[](#arguments-6)

- *file:* filename

##### *Examples:*

[](#examples-6)

```
$name = file_get_name("/etc/passwd");
// $name => passwd
$name = file_get_name("/etc/nginx/nginx.conf");
// $name => nginx
```

### curl

[](#curl)

---

Complex function for web crawling. Supports multithreading (MT).

##### *Arguments:*

[](#arguments-7)

- *urls:* single URL or URL list
- *settings:* associative array:

    KeyDescriptionCURLOPT\_\*All such keys are transfered to cURL handler as is.threadsNumber of threads (`5`).retryNumber of retries (`1`).sleepSleep in seconds before retry (`5`).delayDelay in seconds between MT loops (`0`).verboseBe verbose (`false`).formatReturn format: `simple`, `array` or `complex`.checkerAdditional check to trigger retry. Function receives `url` and `ch` (cURL handler).modifyContentModify HTML content. Function receives `url` and `content`.

##### *Examples:*

[](#examples-7)

```
$content = curl("http://github.com");
preg_match('~(.*?)~', $content, $title);
@ $title = $title[1];
// $title => How people build software · GitHub
```

```
$content = curl("http://ejz.ru/ua", array(
    CURLOPT_USERAGENT => "Custom User Agent"
));
// $content => Custom User Agent
```

### template

[](#template)

---

Implements templating.

##### *Arguments:*

[](#arguments-8)

- *template:* template file
- *vars:* variables that are used inside

##### *Examples:*

[](#examples-8)

```

 'test title',
    'body' => 'test body',
);
echo template("test.tpl", $vars);
```

### validateHost

[](#validatehost)

---

Validate a hostname.

##### *Arguments:*

[](#arguments-9)

- *host:* hostname

### host

[](#host)

---

Extracts (and validates) hostname from an URL.

##### *Arguments:*

[](#arguments-10)

- *url:* URL

##### *Examples:*

[](#examples-9)

```
echo host("http://site.com");
// => site.com
```

### curdate

[](#curdate)

---

Returns current date in `Y-m-d` format.

##### *Arguments:*

[](#arguments-11)

- *days:* add some days to current date (`0`)

##### *Examples:*

[](#examples-10)

```
echo curdate();
// => 2016-09-20
echo curdate(-1);
// => 2016-09-19
```

### now

[](#now)

---

Returns current datetime in `Y-m-d H:i:s` format.

##### *Arguments:*

[](#arguments-12)

- *seconds:* add some seconds to current time (`0`)

##### *Examples:*

[](#examples-11)

```
echo now();
// => 2016-09-20 12:20:58
echo now(-1);
// => 2016-09-20 12:20:57
```

### getTagAttr

[](#gettagattr)

---

Returns tag attributes (or a certain one).

##### *Arguments:*

[](#arguments-13)

- *tag:* string that represents a tag
- *attr:* get a certain attribute (`null`)

##### *Examples:*

[](#examples-12)

```
$tag = 'About';
$attrs = getTagAttr($tag);
// $attrs => [href => /about/]
$href = getTagAttr($tag, 'href');
// $href => /about/
```

### nsplit

[](#nsplit)

---

Splits a string to an array, strings are trimed, empty one are filtered out.

##### *Arguments:*

[](#arguments-14)

- *string:* your string you want to explode

##### *Examples:*

[](#examples-13)

```
$string = "\nhello\n world!\n\n";
$lines = nsplit($string);
// $lines => ["hello", "world"]
```

### is\_closure

[](#is_closure)

---

Check whether or not argument is a callable closure.

##### *Arguments:*

[](#arguments-15)

- *obj:* closure to check

##### *Examples:*

[](#examples-14)

```
$call = function () {
    echo "Hello, world!\n";
};
$flag = is_closure($call);
// $flag => true
```

### is\_ip

[](#is_ip)

---

Check whether or not argument is a valid IP address.

##### *Arguments:*

[](#arguments-16)

- *ip:* IP to check

##### *Examples:*

[](#examples-15)

```
$flag = is_ip("192.168.0.1");
// $flag => true
$flag = is_ip("0.0.0.0");
// $flag => true
$flag = is_ip("1.0.0");
// $flag => false
$flag = is_ip("256.0.0.0");
// $flag => false
```

### str\_replace\_once

[](#str_replace_once)

---

Replace just one occurrence of the search string with the replacement string.

##### *Arguments:*

[](#arguments-17)

- *needle:* string you search
- *replace:* replacement value
- *haystack*: string being searched

##### *Examples:*

[](#examples-16)

```
echo str_replace_once("o", "O", "Hello, world!");
// => HellO, world!
```

### Authors

[](#authors)

- [Ejz Cernisev](http://ejz.ru) | [GitHub](https://github.com/Ejz) |

### License

[](#license)

[Core](https://github.com/Ejz/Core) is licensed under the [WTFPL License](https://en.wikipedia.org/wiki/WTFPL) (see [LICENSE](LICENSE)).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea63e34d79d9383a876c7c107f9175746dea8a8b48974a797e39430e135f16a8?d=identicon)[macropage](/maintainers/macropage)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/michabbb-ejz-core/health.svg)

```
[![Health](https://phpackages.com/badges/michabbb-ejz-core/health.svg)](https://phpackages.com/packages/michabbb-ejz-core)
```

###  Alternatives

[outl1ne/nova-inline-text-field

A Laravel Nova inline text field.

23284.1k2](/packages/outl1ne-nova-inline-text-field)

PHPackages © 2026

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