How to Remove the Last Character of a String in PHP
If you need to remove the last character of a string in PHP, then you can do the following:
Option 1 – Using rtrim()
Syntax: rtrim($string, …
61 articles about php development, tools, and best practices
If you need to remove the last character of a string in PHP, then you can do the following:
rtrim()Syntax: rtrim($string, …
If you need to create a PHP function that returns multiple values, then you can do one of the following.
arrayfunction …
Read Article →
If you have a single-dimensional array, and want to break it into chunks, you can use the array_chunks method.
It takes 3 arguments:
If you have some HTML input submitted from a user to your application, before saving it to the database, you may want to strip all <script> tags …
Below is a quick and easy way to recursively delete all files and folders in a given path using PHP.
function destroy_dir($dir) {
if (!is_dir($dir) …
Read Article →
If you have a busy PHP driven website and don’t want to make constant queries to the database for each user that will see the same data, then …
Read Article →Let’s take a really common example. Say we want to follow redirects with cURL for google.com. It is common to curl follow redirect a URL.
PHP is a powerful scripting language created for the web.
It has come a long way since it’s initial inception in 1994.
It was originally created to …
Read Article →<?php
//fromDate
2014 - 01 - 22
//toDate
2014 - 02 - 20
//$arr
Array(
[0] = & gt;
Array(
[ISO_DATE] = & gt;
2014 - …
Read Article →
Sometimes you will need to retrieve the GET variables passed into the current page URI or you will have a URL string to work from which contains …
Read Article →There are times when you want to remove a specific HTML tag from an HTML block of text.
This could be an anchor(<a/>) or an image(<img/>) …
I often need a quick and easy few lines to retrieve some data from MySQL using Joomla without all the MVC nonsense that usually goes about this topic. …
Read Article →This is really actually meant for future reference for myself as lately I’ve been doing quite a lot of Joomla! mysql coding and have used the …
Read Article →I was busy with a custom component in Joomla, and it stored it’s own user_details based off of the main users table, but if the details were …
Read Article →Sometimes you need to extract multiple email addresses from a string and the following function will make all your dreams come true.
function …
Read Article →
Ever wanted to have a dropdown that automatically showed the current year and the few years before it?
This is a quick and easy way to do exactly …
Read Article →Recently I had to create a code/username maker to fit into a certain type of pattern so that all “broker codes” (as they were called) …
Read Article →You heard it right! split() is officially a deprecated function. That means that you can still use it if you are really brave and it will work …
Read Article →It’s really very simple to convert times in different timezones using the following function.
function dateTimeConversion($datetime, …
Read Article →
With the following function you can easily convert an integer containing seconds to a nice days, hours, minutes, seconds string or array.
function …
Read Article →
If you would like to get the amount of hours between 10:00 and 12:00 then use this!
I needed this for a timesheet calculator where users entered start …
Read Article →It’s very simple to get the difference in hours using PHP. Here’s a quick function that takes two time strings and returns the difference: …
Read Article →A common error which occurs with foreach loops is the standard “Invalid argument supplied for foreach()” whch gets thrown up as a warning. …
Read Article →I usually store data from a textarea directly to the database as is, then once I retrieve it back into HTML I use that lovely PHP function nl2br() to …
Read Article →