Related Content
Generating Colour Palettes From Images In PHP
A common web design pattern is to incorporate an image into the design of the page. This creates a tighter integration with the image and the rest of the page.
The main issue in designing a page around the image is that the colours of the page must match the image. Otherwise this creates a dissonance between the image and the styles of the site.
Validating XML Files With XML Schema Definitions In PHP
XML is a useful format for configuration, data storage, and transmitting data from one system to another. As a human readable format that can be easily read by machines it quickly gained favor in lots of different systems as a mechanism for data storage.
Creating A Character Bitmap In PHP
I was watching a video from NDC by Dylan Beattie the other day on The Story of Typography and a particular section stood out to me.
Approximating Pi Using A Circle And A Square
Pi day was a few weeks ago, but I came across this simple approximation of pi recently and decided to put together an example in PHP since it seemed pretty simple.
This approximation of pi centers around a real world example, but we can simulate this using some code.
Drawing A Parabolic Curve With Straight Lines In PHP
A parabolic curve is a type of curve where every point is an equal distance from a focal point. There a number of different way to generate this sort of curve using math, but one of the simplest is to use straight lines to create the illusion of the curve.
Recreating Spotify Wrapped In PHP
I quite like the end of the year report from Spotify that they call "Wrapped". This is a little application in which they tell you what your favorite artist was and what sort of genres you listened to the most during the year.
Comments
Submitted by Ben Althauser on Mon, 04/13/2009 - 23:18
PermalinkSubmitted by Amir on Sun, 10/16/2016 - 01:13
PermalinkSubmitted by vipjatt on Thu, 06/01/2017 - 03:19
PermalinkSubmitted by kvanacht on Tue, 01/23/2018 - 05:49
PermalinkI 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:23
PermalinkHello 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:53
PermalinkQuite 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 giHlZp8M8D on Thu, 07/22/2021 - 20:58
PermalinkReally liked this post, thanks!
Submitted by DanielFlupt on Thu, 07/29/2021 - 15:21
PermalinkHi,
Lovely Script.
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:24
PermalinkYou mean something like this?
Submitted by giHlZp8M8D on Fri, 01/28/2022 - 08:37
PermalinkAdd new comment