This is a very common PHP question, how to remove last character from string in PHP?
So here are three ways how to delete last character from string in PHP.
[inttf_post_ad1]
Method 1 - PHP: Remove Last Character from String using substr and mb_substr
substr and mb_substr commands usage
substr($string, 0, -1);
mb_substr($string, 0, -1);
substr and mb_substr example:
$string = "This is test string..";
echo $string . "\n";
// substr function
echo "substr: " ....
This is guide, howto install SVN (Subversion) server on Fedora 31/30/29/28, CentOS 8.0/7.7/6.10, Red Hat (RHEL) 8.0/7.7/6.10.
What is SVN (Subversion)?
Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of "time...
This is guide howto install Nginx with PHP 7.2.12 and PHP-FPM on Fedora 29/28/27, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10. PHP-FPM is easier to use and configure than FastCGI and some tests says that PHP-FPM is even much more efficient than FastCGI.
Nginx (engine x) is a robust, small and high performance http server, reverse proxy server and also mail proxy server.
PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for...
This is guide, howto Install Oracle (Sun) Java JDK and JRE 8 update 191 (8u191) on Fedora 29/28/27/26, CentOS 7.5/6.10, Red Hat (RHEL) 7.5/6.10.
If you're looking installation instruction for older Oracle Java versions, then check Install Sun/Oracle Java JDK/JRE 7 on Fedora 24/23/22/21/20/19, CentOS/Red Hat (RHEL) 7.2/6.9/5.11 or Install Sun/Oracle Java JDK/JRE 6 on Fedora 20/19/18, CentOS/Red Hat (RHEL) 6.5/5.10.
[inttf_post_ad1]
What's new in Oracle Java 8
Java...
This is a quick method to check with using cURL that Nginx/Apache (or any other web server) compression with Nginx ngx_http_gzip_module (gzip), Nginx google/ngx_brotli (br), Apache mod_brotli (br), Apache mod_gzip (gzip) and Apache mod_deflate (deflate) is working. Only the remote server headers are needed.
Check that the Nginx/Apache Compression is Working
[inttf_post_ad1]
Get headers
curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://www.if-not-true-then-false.com
-s option...
This is simple function to add English ordinal number suffix after normal number. Function takes number as a parameter and returns number with suffix, like:
1st, 2nd, 3rd, 4th, 5th, 6th...
[inttf_post_ad1]
This is example table of ordinal numbers 1 to 100
1st 2nd 3rd 4th 5th 6th 7th 8th 9th ...
LAMP (Linux, Apache, MariaDB/MySQL, PHP) server is very powerful server setup behind any website or web based service. This guide is collection of Fedora/CentOS/Red Hat (RHEL), Apache, MariaDB/MySQL and PHP install guides.
Today the Internet is full of instructions, which promises a LAMP server installation with a "One-Liner", and so forth. In fact, these "One-Liner" instructions assume that, Linux is already installed and installs just AMP (Apache, MariaDB/MySQL, PHP) pakages, without any...
I just wrote guide, howto install SVN (Subversion) Server on Fedora, CentOS and Red Hat (RHEL). No I decided to write more information about SVN Access Control. This guide works if you have installed Apache, Subversion (SVN) and mod_dav_svn on any Linux system, like Ubuntu, Debian, Arch, Gentoo, not only Fedora, CentOS or Red Hat (RHEL).
[inttf_post_ad1]
Setup SVN (Subversion) Access Control with Apache and mod_authz_svn
1. Change root user
su -
## OR ##
sudo -i
2....
PHP's ucfirst function is very usefull when you want to change words first letters to uppercase and other letters to lowercase. Currently on PHP does not have a multibyte (UTF-8) version of ucfirst function. So I decided write my own multibyte mb_ucfirst function.
Perhaps the multibyte version of ucfirst function is added later on PHP, so that's why is better add this function only if it does not already exist.
[inttf_post_ad1]
<?php
if (!function_exists('mb_ucfirst'))...
Please note: This guide still working normally if you want install Sun/Oracle Java 7, but if you want Java 8 version, then check Install Oracle Java JDK/JRE 8 on Fedora, CentOS/RHEL.
This is guide, howto Install Sun/Oracle Java JDK and JRE 7 CPU (7u79) and PSU (7u80) on Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12, CentOS 7.2/6.8/5.11, Red Hat (RHEL) 7.2/6.8/5.11. Read more, what is difference between CPU and PSU release.
If you're looking instruction for Sun/Oracle Java JDK/JRE...
This is guide, howto install latest Eclipse Mars.2 4.5.2 on Fedora, CentOS and Red Hat (RHEL). This guide should work with Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12, CentOS 7.2/6.8/5.11 and Red Hat (RHEL) 7.2/6.8/5.11 and even with earlier versions. Latest working version on CentOS/RHEL 5.11 is Eclipse Luna 4.4.2.
Eclipse is a multi-language software development environment comprising an integrated development environment (IDE) and an extensible plug-in system. It is written primarily in...
I think every PHP coders have come accross Arrays and stdClass Objects (belongs to PHP Predefined Classes). Sometimes it's very useful convert Objects to Arrays and Arrays to Objects. This is easy if arrays and objects are one-dimensional, but might be little tricky if using multidimensional arrays and objects.
This post defines two ultra simple recursive function to convert multidimensional Objects to Arrays and multidimensional Arrays to Objects.
[inttf_post_ad1]
Function to...
Simple PHP function that formats the bytes to the desired form. Possible unit options are:
Byte (B)
Kilobyte (KB)
Megabyte (MB)
Gigabyte (GB)
Terabyte (TB)
Petabyte (PB)
Exabyte (EB)
Zettabyte (ZB)
Yottabyte (YB)
Function takes three parameter: (bytes mandatory, unit optional, decimals optional)
[inttf_post_ad1]
PHP byteFormat function for formatting bytes
<?php
function byteFormat($bytes, $unit = "", $decimals = 2) {
$units = array('B' =>...
PHP has large number of predefined constants. This HOWTO will present the seven most important, most practical and most useful PHP Magic Constants.
__FILE__ - The full path and filename of the file.
__DIR__ - The directory of the file.
__FUNCTION__ - The function name.
__CLASS__ - The class name.
__METHOD__ - The class method name.
__LINE__ - The current line number of the file.
__NAMESPACE__ - The name of the current namespace
This is example PHP script with comments,...
I was using simple function to calculate difference between two dates and timestamps until I noticed, it's not working correctly in long intervals. It's very easy to calculate difference between two timestamps in seconds, but it's much more complicated print difference in human readable format. The Internet can be found in a wide range of ways to do this thing, but as a rule they use a fixed amount of seconds for the year and the month. So if we calculate year with using 365 or 365.25 days and...
In many cases, it is really useful to know the exact time for how long a PHP script is running or how long will take PHP web page load. On the other hand it is also useful to know that how long a particular script operation or part of page load will take.
Following PHP Timing class is very simple to use, only create class and start timing and stop timing. Elapsed time function can be used also (elapsed time is calculated from script start time). Statistics can be displayed in...
This is quick SVN (Subversion) tip, howto remove added file from SVN repository without deleting file from local filesystem.
[inttf_post_ad1]
Remove File From SVN Repository and Keep Local File
svn delete --keep-local path/to/file.example
Real example:
svn delete --keep-local css/test.css
[inttf_post_ad2]
Real world usage example
Adding a whole directory add a file that was not intended to SVN reads, but should be retained locally.
svn add css/
A ...
This is quick guide, howto Backup (dump) and Restore (load) SVN (Subversion) repository on Linux. This is actually very simple and important task. SVN backup and restore is useful when you want to move your repos to new server or you need to recover your data. I assume here that you have Subversion (SVN) installed and you have existing repositories. If you installed and created testrepo with earlier guide then you can check real examples.
[inttf_post_ad1]
1. Backup (dump) SVN...
I like very much Ethan Schoonover Solarized color palette. So I decided write a guide, howto get Solarized colors to most commonly used Linux terminals (Gnome-Terminal, Konsole, XFCE Terminal, Mate-Terminal), Text editors (Gedit, Vim) and IDEs (Eclipse, NetBeans). These are not my projects, so the greatest honor belongs, of course, these projects owners and Ethan Schoonover.
1. Install Needed Tools (git, mercurial, 7-zip)
2. Create and Change to Solarized Directory
3. Solarized...
This is a PHP, PDO and SQLite3 example, which demonstrates the SQLite3 databse usage with PHP-PDO. The PHP / PDO / SQLite3 example code demonstrates following things, and their use:
Create / Connect SQLite3 databases
Use SQLite3 file and memory databases
Create tables in SQLite3 database
Use SQLite3 db different datetime formats
Insert data to SQLite3 database
PDO / SQLite3 prepared statements
Bind parameters to statement variables
Bind values to statement variables
Quote a...
1
2
Next »