Generating Histogram Colour Analysis Graphs From Images In PHP
If you've ever looked at the settings in a digital camera, or have experience with image processing programs like GIMP, then you may have seen a colour histogram. This is a simple graph that shows the amount of different shades of colour are present in the image.
PHP:CSI - To Switch, Or Not To Switch?
I was writing unit tests for a API mapping function recently and came across this interesting issue. The code I was writing tests for was in a legacy codebase that I was making changes to, and it made sense to have some unit tests in there before I started work to ensure everything worked before and after.
Drupal 9: Generating Header Images For Pages Of Content Using PHP
Embedding image within pages of content helps both within the design of the page and when shared on social media. If you set up meta tags to point at a particular image then that image will appear when the page is shared on social media. This makes your page stand out more.
Using PSR-4 With Composer
The PHP Standards Recommendations (called PSR) are a set of standards that aim to make certain aspects of working with PHP easier.
Generating A PDF From A Web Page Using PHP And Chrome
Generating a PDF document from a web page through PHP can be problematic. It's often something that seems quite simple, but actually generating the document can be difficult and time consuming.
PHP:CSI - Date Is Less Than One Month Ago
Working with logic surrounding dates can sometimes be difficult and it's fairly common to come across really subtle date and time based bugs.
I was recently shown a bug in a PHP application that looks like it should be working at face value, but doesn't actually produce the correct result.
Submitted by Ben Althauser on Mon, 04/13/2009 - 23:18Permalink
Submitted by Amir on Sun, 10/16/2016 - 01:13Permalink
Submitted by vipjatt on Thu, 06/01/2017 - 03:19Permalink
Submitted by kvanacht on Tue, 01/23/2018 - 05:49Permalink
I just had to swap $total and 100 over for my purposes, i.e returning 100/200 as 50%.
Submitted by Tim on Wed, 03/03/2021 - 15:23Permalink
Hello Philip, that formula does not generate the correct %, then I write the correct one: (number * 100) / total:
return round(($number * 100) / $total, 2);
Submitted by Rafa G on Thu, 07/22/2021 - 15:53Permalink
Quite right. It must have been right at some point but it's clearly been wrong for a while.
Thanks for the correction! I've updated the code.
Submitted by philipnorton42 on Thu, 07/22/2021 - 20:58Permalink
Really liked this post, thanks!
Submitted by DanielFlupt on Thu, 07/29/2021 - 15:21Permalink
But I am looking for one that takes a value, EG Dollars, and multiples it by 11% and gives an answer. Any help?
Thanks in advance.
Submitted by Michael C Hutchinson on Fri, 01/28/2022 - 05:24Permalink
You mean something like this?
Submitted by philipnorton42 on Fri, 01/28/2022 - 08:37Permalink
Add new comment