13
Random Data Generator Class
As a programmer, I’ve often needed to generate random data of one kind or another, whether it be names, addresses or just random text. Such a task is usually very boring and tedious, and I’ve thought on several occassions ‘I should really write a tool to automate this’. Well now I have…
Introducing SPF_Random
SPF_Random is the latest class to join Si’s PHP Framework (SPF) and includes methods to generate various forms of random data:
- names (forenames, surnames and full names)
- addresses
- postcodes
- phone numbers
- dates
- job titles
- lorem ipsum text (words or paragraphs)
It’s not perfect (addresses and phone numbers are UK oriented for example) and I’m sure there are better solutions elsewhere on the interweb; but it’s certainly a very quick and simple way to generate personal details for a hundred random people. Plus it’s a completely stand-alone class, you don’t need to download the whole framework to be able to use it.
For the future I’m thinking of adding IP addresses, alphanumeric strings and item lists (especially useful for <select> lists).
The job titles one would be hilarious with a little tweaking
Leave a comment