PHPackages                             nguyenanhung/codeigniter-basic-helper - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. nguyenanhung/codeigniter-basic-helper

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

nguyenanhung/codeigniter-basic-helper
=====================================

CodeIgniter - Basic Helper

v1.7.1(1mo ago)927.6k51GPL-3.0PHPPHP &gt;=5.6

Since Aug 6Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/nguyenanhung/codeigniter-basic-helper)[ Packagist](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[ Docs](https://github.com/nguyenanhung/codeigniter-basic-helper)[ RSS](/packages/nguyenanhung-codeigniter-basic-helper/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (18)Versions (105)Used By (1)

CodeIgniter Basic Helper
========================

[](#codeigniter-basic-helper)

[![Latest Stable Version](https://camo.githubusercontent.com/8b1142450a21b105b729881cda56501591da71c1bfb55f0961b1eee2af70b25a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[![Total Downloads](https://camo.githubusercontent.com/11bec9629119b05deb71619f700bde3d2c7eddb105a93aa192b37e1b08180296/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[![Daily Downloads](https://camo.githubusercontent.com/f49bbde94e7df9570d0034abe3fa7d1c9ac13bb1f11cf72e50f09fd17d386bb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[![Monthly Downloads](https://camo.githubusercontent.com/b9ccf559ebdf9a338084eb8b474d4eeb40b70487632aef0b22a21222bd26b991/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[![License](https://camo.githubusercontent.com/52c5819c4715111070c529505e1438f60b191fce36bfedcf79da64aca905b033/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)[![PHP Version Require](https://camo.githubusercontent.com/5788c21f9dc692675f184f21a3fe2c75f768b1f9556080bc0d242ac3e0eab3be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6e677579656e616e68756e672f636f646569676e697465722d62617369632d68656c7065722f706870)](https://packagist.org/packages/nguyenanhung/codeigniter-basic-helper)

Summary
-------

[](#summary)

Some basic helpers when using with CodeIgniter 3.

Can be included in many other code sets or frameworks, however, there are some functions that require the `CodeIgniter`framework, however it does not affect the performance

In case of integrating this package into other frameworks, sources other than `CodeIgniter`, you need to install the `nguyenanhung/polyfill-codeigniter-built-in` package for best use

Some frameworks I often use with this package are

- CodeIgniter
- Slim framework
- FuelPHP
- PhalconPHP
- Laravel

Table of Contents
-----------------

[](#table-of-contents)

- [CodeIgniter Basic Helper](#codeigniter-basic-helper)
    - [Summary](#summary)
    - [Table of Contents](#table-of-contents)
    - [1 số helper được hỗ trợ sẵn](#1-s%E1%BB%91-helper-%C4%91%C6%B0%E1%BB%A3c-h%E1%BB%97-tr%E1%BB%A3-s%E1%BA%B5n)
        - [AlphaID Helper](#alphaid-helper)
        - [Array Helper](#array-helper)
        - [Assets Helper](#assets-helper)
        - [Blogspot Helper](#blogspot-helper)
        - [Bytes Helper](#bytes-helper)
        - [Chart Render Helper](#chart-render-helper)
        - [Common Helper](#common-helper)
        - [Database Helper](#database-helper)
        - [Date Helper](#date-helper)
        - [Debug Helper](#debug-helper)
        - [ENV Helper](#env-helper)
        - [Escape Helper](#escape-helper)
        - [Facebook Helper](#facebook-helper)
        - [File Helper](#file-helper)
        - [Form Helper](#form-helper)
        - [Gravatar Helper](#gravatar-helper)
        - [HTML Helper](#html-helper)
        - [Image Helper](#image-helper)
        - [IP Helper](#ip-helper)
        - [Meta Helper](#meta-helper)
        - [Money Helper](#money-helper)
        - [NanoID Helper](#nanoid-helper)
        - [Number Helper](#number-helper)
        - [Paging Helper](#paging-helper)
        - [PlaceHolder Helper](#placeholder-helper)
        - [Request Helper](#request-helper)
        - [Security Helper](#security-helper)
        - [Sentry Helper](#sentry-helper)
        - [String Helper](#string-helper)
        - [Text Helper](#text-helper)
        - [TinyUrl Helper](#tinyurl-helper)
        - [URL Helper](#url-helper)
        - [UUID Helper](#uuid-helper)
        - [VN Province Helper](#vn-province-helper)
        - [Video Embed Helper](#video-embed-helper)
        - [XML Helper](#xml-helper)
        - [Simple RESTful Helper](#simple-restful-helper)
        - [Simple cURL Helper](#simple-curl-helper)
        - [Simple Image Library](#simple-image-library)
    - [Maintainer &amp; Supporter](#maintainer--supporter)

Some Supported Helpers
----------------------

[](#some-supported-helpers)

Here is a list of supported Helpers in this library

### AlphaID Helper

[](#alphaid-helper)

- Helper Function: `generateAlphaId` - Function to generate a unique Id `4ew68i32xc` based on an input int like `1234`

### Array Helper

[](#array-helper)

- Helper Function: `arrayToObject` - Function to convert an array to an object
- Helper Function: `to_array` - Converts a string or an object to an array.
- Helper Function: `arrayToXml` - Function to help convert array into an XML string
- Helper Function: `removeArrayElementWithValue` - Remove 1 value in the array by key and value
- Helper Function: `arrayRecursiveDiff` - Diff 2 arrays recursively
- Helper Function: `arrayIsAssoc` - Detects if the given value is an associative array.
- Helper Function: `arrayFirstElement` - Returns the first element of an array.
- Helper Function: `arrayLastElement` - Returns the last element of an array.
- Helper Function: `arrayGetElement` - Gets a value in an array by dot notation for the keys.
- Helper Function: `arraySetElement` - Sets a value in an array using the dot notation.

### Assets Helper

[](#assets-helper)

- Helper Function: `assets_url` - Function to get Assets Url, condition for existence of `assets` folder in `public/` folder.

In case in `config.php` file exists `assets_version` variable, it will automatically add version behind the files

CSS, JS

- Helper Function: `static_url` - Function to get Static Resource Url, condition for existence of `config_item('static_url')` configuration in website config. In case in `config.php` file exists `assets_version`variable, it will automatically add version behind the files

CSS, JS

- Helper Function: `templates_url` - Function to get Assets Url, condition for existence of `templates` folder in `public/` folder. In case the `config.php` file contains the variable `assets_version`, it will automatically add the version behind the CSS, JS files
- Helper Function: `editor_url` - Function to get Assets Url, condition that the `assets/editors/` folder exists in the `public/` folder. In case the `config.php` file contains the variable `assets_version`, it will automatically add the version behind the CSS, JS files
- Helper Function: `favicon_url` - Function to get Assets Url, condition that the `assets/favicon/` folder exists in the `public/` folder. In case the `config.php` file contains the `assets_version` variable, it will automatically add the version behind the

CSS, JS files

- Helper Function: `favicon_html_tag`- Function to get the HTML segment representing the Favicon based on the input favicon folder URL
- Helper Function: `storage_url` - Need config `storage_url` item in config.php file. Example: `$config['storage_url'] = 'https://storage.nguyenanhung.com/';`
- Helper Function: `go_url` - Need config `go_url` item in `config.php` file. Eg: `$config['go_url'] = 'https://go.nguyenanhung.com/';`
- Helper Function: `assets_mobile` - Get the assets path of the mobile interface (rarely used, maintained for old projects)
- Helper Function: `assets_themes` - Get the assets path of the pc interface (rarely used, maintained for old projects)
- Helper Function: `assets_themes_dashboard` - Get the assets path of the dashboard interface (rarely used, maintained for old projects)
- Helper Function: `assets_themes_comingsoon` - Get the assets path of the coming soon interface (rarely used, maintained for old projects)
- Helper Function: `assets_themes_error` - Get the assets path of the error interface (rarely used, maintained for old projects) maintenance for old projects)
- Helper Function: `cdn_js_url` - JS, CSS resource from Cloudflare CDN
- Helper Function: `google_fonts_url` - Google Font resource
- Helper Function: `bootstrapcdn_url` - CDN resource from Bootstrap

### Blogspot Helper

[](#blogspot-helper)

- Helper Function: `blogspotDescSortWithPublishedTime` - Sort feed data from blogspot by Published Time
- Helper Function: `blogspotUSort` - Sort feed data from blogspot by USort and Published Time by DESC
- Helper Function: `blogspotFormatInformationItem` - Format input data blogspot item

### Bytes Helper

[](#bytes-helper)

- Helper Function: `bytesHumanFormat` - Display readable content format from data bytes

### Chart Render Helper

[](#chart-render-helper)

- Helper Function: `bear_framework_default_get_data_chart`
- Helper Function: `bear_framework_default_get_data_chart_report`

### Common Helper

[](#common-helper)

- Helper Function: `isEmpty ` - Checks whether an input is empty
- Helper Function: `defaultCompressHtmlOutput ` - Compresses HTML output, default configure
- Helper Function: `generateRandomUniqueId ` - Generates a random Unique ID string, using UUID
- Helper Function: `generateRandomNanoUniqueId ` - Generates a random Unique ID string, using NanoID

### Database Helper

[](#database-helper)

- Helper Function: `generate_list_id_with_parent_id ` - Generates a list of IDs, containing dependent subsets of

that ID. Example: Used in case you want to display the content of the parent category and the child categories in the same page content

### Date Helper

[](#date-helper)

- Helper Function: `dayFloor` - Function to get the distance between 2 days
- Helper Function: `getZuluTime` - Function to get the date parameter according to Zulu time
- Helper Function: `iso_8601_utc_time` - Similar to the getZuluTime function
- Helper Function: `getYesterday` - Function to get the previous day
- Helper Function: `smart_bear_date_range` - Get an array of data containing dates according to the distance
- Helper Function: `format_datetime_vn` - Format the date information according to Vietnamese style
- Helper Function: `get_start_and_end_date_for_week` - Get the first and last days of a week

### Debug Helper

[](#debug-helper)

Các hàm này dùng debug

- Helper Function: `dd`
- Helper Function: `ddd`
- Helper Function: `dump`

### ENV Helper

[](#env-helper)

- Helper Function: `bear_get_env` - Hàm lấy giá trị từ file .env

### Escape Helper

[](#escape-helper)

- Helper Function: `bear_framework_basic_clean_str` - Simple Clean Input String

### Facebook Helper

[](#facebook-helper)

- Helper Function: `widget_facebook_div_init` - Function to create ``
- Helper Function: `widget_facebook_script_init` - Function to create init script in case JS needs to be embedded

Facebook

- Helper Function: `widget_facebook_comments` - Function to create facebook comment box
- Helper Function: `widget_facebook_share_button` - Function to create facebook share button
- Helper Function: `widget_facebook_like_button` - Function to create facebook like button
- Helper Function: `widget_facebook_save_button` - Function to create save content button to facebook

### File Helper

[](#file-helper)

- Helper Function: `formatSizeUnits` - Function to format 1 input int into 1 format for easy read file size
- Helper Function: `generateFileIndex` - Automatically generate the content of the file `index.html`
- Helper Function: `generateFileHtaccess` - Automatically generate the content of the file `.htaccess`
- Helper Function: `generateFileReadme` - Automatically generate the content of the file `README.md`
- Helper Function: `makeNewFolder` - The function creates a new folder and generates 3 files in it: `README.md`, `index.html`, `.htaccess`. Create additional `.gitkeep` file if the second parameter passed is true
- Helper Function: `new_folder` - Similar function to `makeNewFolder`
- Helper Function: `scan_folder` - Scan and get list of data information in folder
- Helper Function: `getAllFileSizeInFolder` - Get all File size in Folder
- Helper Function: `getAllFileInFolder` - Get all File in Folder

### Form Helper

[](#form-helper)

- Helper Function: `join_value_multiple` - Join Value Multiple

### Gravatar Helper

[](#gravatar-helper)

- Helper Function: `bear_framework_show_gravatar` - Show Gravatar URL with Custom Size and Username

### HTML Helper

[](#html-helper)

- Helper Function: `meta_dns_prefetch`
- Helper Function: `meta_property`
- Helper Function: `tachPage`
- Helper Function: `stripHtmlTag`
- Helper Function: `strip_only_tags`
- Helper Function: `tracking_google_analytics`
- Helper Function: `tracking_google_gtag_analytics_default`
- Helper Function: `bear_framework_show_jsonld_script`

### Image Helper

[](#image-helper)

- Helper Function: `google_image_resize` - Resize Image using Google Gadget Proxy
- Helper Function: `google_image_proxy_dns_prefetch` - Function to provide DNS Prefetch in case of using `google_image_resize`
- Helper Function: `wordpress_proxy` - Resize &amp; Cache Image using WordPress Proxy
- Helper Function: `wordpress_proxy_dns_prefetch` - Function to provide DNS Prefetch in case of using `wordpress_proxy`
- Helper Function: `bear_framework_image_url` - Function to format Image Url - specific to BEAR framework
- Helper Function: `create_image_thumbnail` - Function to create thumbnail - specific to BEAR framework

### IP Helper

[](#ip-helper)

- Helper Function: `getIPAddress` - Function to get the user's actual IP address
- Helper Function: `getIPAddressByHaProxy` - Function to get the user's actual IP address but on the server running Ha Proxy, through the variable `HTTP_X_FORWARDED_FOR`
- Helper Function: `validateIP` - Function to validate whether a string is an IP. TRUE if it is an IP
- Helper Function: `validateIPV4` - Function to validate whether a string is an IP v4. TRUE if it is an IP
- Helper Function: `validateIPV6` - Function to validate whether a string is an IP v6. TRUE if it is an IP
- Helper Function: `getIpInformation` - Initiate a request to `IP-API` to get information about the IP address

### Meta Helper

[](#meta-helper)

- Helper Function: `setupMetaDnsPrefetch` - Function to generate a similar HTML Dns Prefetch segment

### Money Helper

[](#money-helper)

- Helper Function: `money_number_format` - format money currency will detect the current locale

### NanoID Helper

[](#nanoid-helper)

This helper uses the `hidehalo/nanoid-php` package to generate a random Id code that is small, lightweight and much safer than UUID.

Currently, using nanoid is a trend compared to traditional uuid

To use this package, you need to install the `nguyenanhung/nanoid-helper` package by command `composer require nguyenanhung/nanoid-helper`

- Helper Function: `randomNanoId`

### Number Helper

[](#number-helper)

- Helper Function: `convertNumberToWords` - Effect of converting a number into words, for example `123`to `One Hundred Twenty Three`

### Paging Helper

[](#paging-helper)

- Helper Function: `view_paginations`
- Helper Function: `view_more`
- Helper Function: `select_page`
- Helper Function: `get_paginations_title`
- Helper Function: `get_paginations_number`
- Helper Function: `bear_framework_news_view_pagination` - Pagination function specifically for BEAR Project

### PlaceHolder Helper

[](#placeholder-helper)

- Helper Function: `placeholder_img`

### Request Helper

[](#request-helper)

- Helper Function: `sendSimpleGetRequest` - Execute a simple request using CURL with GET method
- Helper Function: `sendSimpleRestfulExecuteRequest` - Execute a simple request to Restful API using CURL
- Helper Function: `bear_post_async_request` - Make an asynchronous POST request - Execute asynchronous POST request within the site without waiting for a response =&gt; No impact, no delay in the running process
- Helper Function: `get_http_response_code` - Get HTTP Response Code with `get_headers`

### Security Helper

[](#security-helper)

- Helper Function: `xssValidation` - Validate whether the input data is vulnerable to XSS or not. This function does not have an escape function, if you want, install the package `nguyenanhung/security`

### Sentry Helper

[](#sentry-helper)

- Helper Function: `log_to_sentry` - Logging to Sentry via Monolog Handler

### String Helper

[](#string-helper)

- Helper Function: `countStringsInText` - Function to count the number of words in a text paragraph
- Helper Function: `findMiddleInString` - Function to get the string between the start string and the end string
- Helper Function: `str_insert` - Inserts one or more strings into another string on a defined position.
- Helper Function: `str_between` - Return the content in a string between a left and right element.
- Helper Function: `str_after` - Return the part of a string after a given value.
- Helper Function: `str_before` - Get the part of a string before a given value.
- Helper Function: `str_limit_words` - Limit the number of words in a string. Put value of $end to the string end.
- Helper Function: `str_limit_characters` - Limit the number of characters in a string. Put value of $end to the string end.
- Helper Function: `str_contains` - Tests if a string contains a given element
- Helper Function: `str_ignore_contains` - Tests if a string contains a given element. Ignore case sensitivity.
- Helper Function: `str_starts_with` - Determine if a given string starts with a given substring.
- Helper Function: `str_ignore_starts_with` - Determine if a given string starts with a given substring. Ignore case sensitivity.
- Helper Function: `str_ends_with` - Determine if a given string ends with a given substring.
- Helper Function: `str_ignore_ends_with` - Determine if a given string ends with a given substring. Ignore case sensitivity.
- Helper Function: `str_after_last` - Return the part of a string after the last occurrence of a given search value.
- Helper Function: `hide_characters` - Convert `nguyenanhung` to `ngxyexanxunx`, acts as a very simple and predictable character encoding function but is necessary to hide something simple

### Text Helper

[](#text-helper)

- Helper Function: `convert_string_utf8_to_vietnamese`
- Helper Function: `clean_allowfullscreen`
- Helper Function: `clean_text`
- Helper Function: `clean_title`
- Helper Function: `clean_text_mobile`
- Helper Function: `bodautru`
- Helper Function: `bodaunhay`
- Helper Function: `searchs_snippets`
- Helper Function: `tags_snippets`
- Helper Function: `tags_clean`
- Helper Function: `highlight_keyword_phrase` - Highlights a keyword within a text string
- Helper Function: `format_keyword_highlight_phrase` - Format Keyword for Function `highlight_keyword_phrase`

### TinyUrl Helper

[](#tinyurl-helper)

- Helper Function: `short_url_with_tinyurl` - ShortUrl helper function based on TinyURL API

### URL Helper

[](#url-helper)

- Helper Function: `encodeId_Url_byHungDEV`
- Helper Function: `decodeId_Url_byHungDEV`
- Helper Function: `convertToLatin`
- Helper Function: `specialCharToNormalChar`
- Helper Function: `alphabetOnly`
- Helper Function: `boDauTiengViet`
- Helper Function: `removeSpecialChar`
- Helper Function: `getPermalinksSEO`
- Helper Function: `share_url` - Create standard sharing URL for social networks, very good support for SEO
- Helper Function: `private_url` - Customize function specifically for CodeIgniter framework
- Helper Function: `private_api_url` - Customize function specifically for CodeIgniter framework
- Helper Function: `cdn_url` - Customize function specifically for CodeIgniter framework
- Helper Function: `images_url` - Customize function specifically for CodeIgniter framework
- Helper Function: `audio_url` - Customize function specifically for CodeIgniter framework
- Helper Function: `append_params_into_url` - Append parameters to URL
- Helper Function: `append_query_string_to_current_url` - Get current URL including query string - Customize function specific to CodeIgniter framework

### UUID Helper

[](#uuid-helper)

- Helper Function: `generate_uuid_v4` - Function to generate a random v4 UUID string

### VN Province Helper

[](#vn-province-helper)

- Helper Function: `check_vn_province_code` - Check Provin Code of some provinces in Vietnam

### Video Embed Helper

[](#video-embed-helper)

- Helper Function: `convert_video_embed_vimeo` - Convert Video URL to Embed Vimeo (rarely used, save here because there are still many old projects using it)
- Helper Function: `convert_video_embed_dailymotion` - Convert Video URL to Embed DailyMotion (rarely used, save here because there are still many old projects using it)
- Helper Function: `convert_video_embed_youtube` - Convert Video URL to Embed YouTube (rarely used, save here because there are still many old projects using it)
- Helper Function: `convert_video_v_embed_youtube` - Convert Video URL to Embed YouTube (rarely used, save here because there are still many old projects using it)
- Helper Function: `youtube_image_thumbnail` - Convert YoutubeID to Youtube Thumbnail URL

### XML Helper

[](#xml-helper)

- Helper Function: `parse_sitemap` - Support function to render content for Sitemap
- Helper Function: `parse_sitemap_index` - Support function to render content for Sitemap Index
- Helper Function: `xml_convert` - Convert Reserved XML characters to Entities
- Helper Function: `xml_get_value` - Get Value from XML string
- Helper Function: `xml_to_json` - Convert XML string to JSON

### Simple RESTful Helper

[](#simple-restful-helper)

Class provides a quick way to call RESTful APIs

- Execute request to RESTful API Service: `SimpleRestful::execute($url, $type, $data)`

### Simple cURL Helper

[](#simple-curl-helper)

Class provides a quick way to call to make external requests, using simple Curl, for example

```
