Archive for the 'PHP' Category

Round to the Nearest - Digit or Multiple?

A few days ago I was working on a project where it was crucial that all the item prices ended up with a 9 after a discount coupon was redeemed, in need for an quick way to round any given number to the closest nine I did a couple of searches on Google and on the PHP Manual and I found the following formula:

round($number / $nearest) * $nearest;

Seemed pretty much straightforward the only problem is… It didn’t worked as I wanted it to! Imagine that $number is 212 and $nearest is 9 for example, the expected result for this scenario should be 209, since 212 is closer to 209 than to 219. However simple arithmetic tell us that:

round(212 / 9) * 9 = 24 * 9 = 216

Continue reading ‘Round to the Nearest - Digit or Multiple?’

Lightweight MySQL Database Wrapper

Today I’m going to share a minimalistic MySQL wrapper you can use to kick start you application database development. This class is made by just seven essential methods that fit in only 101 lines of code.

Continue reading ‘Lightweight MySQL Database Wrapper’

Internet Viral Marketing

As you may have noticed I’ve been away (more of awaaaay) from this blog for quite some time now, the reasons for this are:

  1. Time is short (and money too, who would have thought he?…).
  2. I’ve been getting so many SPAM comments and few or none friendly comments.

Anyway, I’ve been custom web developing for 4 or 5 clients and I’ve this feeling that I’m getting old (I’m twenty now - not a teen anymore =\) and all my ideas and projects are losing towards my clients projects, so I’ve decided that after this I’m out - no more freelance jobs, just my own, at my own way. Things with my web hosting company have also been turning out just great, we have reached the Top 10 (yeah that’s right :) ) here in Portugal, and we have been receiving some selling offers - of course we haven’t accepted any of them.

Continue reading ‘Internet Viral Marketing’

My first five Dollar Bill

Yesterday I got my hands on my very first Lincoln (five dollars) bill, they seem much more older and used than Euro banknotes. As I had already made a Euro note serial number validation algorithm in PHP I thought: “why don’t I do the same for dollar bills?”.

Five Dollars (Front)

Continue reading ‘My first five Dollar Bill’

ISBN-10 and ISBN-13 (EAN) validation with PHP

Since the begining of this year the standart ISBN has now 13 numbers instead of 10 so, I did some functions for validating the ISBN-10 and EAN (works for ISBN-13) with PHP, maybe it’s useful for someone.

Continue reading ‘ISBN-10 and ISBN-13 (EAN) validation with PHP’

Euro banknote validation with PHP

Euro Notes

Have you ever come across a fake Euro banknote? Well, most of us probably have (at least those of us who live in the European Union, like me) - more than 300 thousand Euro banknotes are falsified every year.

Continue reading ‘Euro banknote validation with PHP’

PHP CAPTCHA Decoder

I’ve developed a simple OCR CAPTCHA decoder in PHP, it’s pretty fast and breaks with a 100% success rate all CAPTCHAs that meet some requirements.

Continue reading ‘PHP CAPTCHA Decoder’

PHP Friendly Password Generator

Today I’ll be sharing an algorithm that I use quite a lot, for generating passwords that are easily memorable and spelled - one may also call this type of passwords mnemonic passwords.

Continue reading ‘PHP Friendly Password Generator’

PHP Password Strength Algorithm

I’ve ported the jQuery Password Strength Meter from JavaScript to PHP.

Continue reading ‘PHP Password Strength Algorithm’

PHP Math Library

I’ve just finished my PHP Math Library and Abstraction Layer, I’ve been up all night in order to code it, but it was worth it. I am proud of it.

My PHP Math Library features the following:

Continue reading ‘PHP Math Library’