A function to encode an ugly-looking (query)string into a nicer-looking string (as defined, it looks like a barcode) and a function to decode the string back into the original
string. The 3 characters used for the encoding can be changed easily.
nflector for pluralize and singularize English nouns. This tool can help framework developers to create solutions based on naming conventions rather than on configurations. It
also provides helper functions that allow developers to transform text into and to "UpperCamelCase", "lowerCamelCase", "unserscored_words", "Header Title" or just "normal
text". This can be really useful for existing applications like Wiki, CMS, Forums, etc.. in order to allow them to create friendly URLs and change "WikiWords" inside their
content to "Human text" This Inflector was firstly is a port of Ruby on Rails Inflector. It was ported to PHP for the Akelos Framework, a multilingual Ruby on Rails like
framework for PHP that will be launched soon.
An Alternative to zip checker from this code gallery [ codex.php?id=991&single=1] which you can drop into any app with the DB already set up for you. Tests zip and allows
you to punt with a default bad zip of 00000.
Cleans up a string. Changes certain characters into HTML compatable entities, removes many newlines, removes starting/trailing whitespace. removes multiple spaces. Finally, it
makes it so users can't enter a stream of text to make the page's width screwy.
This code fragment takes a linux path and searches for \r\n into the specified files. It would then replace \r\n with \n. The same logic could be extended to become a global
search and replace as the code supports recusring into directories.
I have been looking high and low for a free dictionary. But no luck. So, the following .sql file is a dump of an English dictionary with three additional fields. One to
describe if the word is a noun or verb, a soundex value and a metaphone value. Both soundex and metaphone functions and descriptions are available in PHP documentation.
This is a class that will format an array of scalars (like strings) neatly into an arbitrary number of equal sized columns. Uses an HTML table to do this, wrapping from left
to right. Modelled after the output from the format_page() SimulEfun in the Nightmare Mudlib.
This Function allows it to highlight assigned Parts (needle) of a string (hystack) with pre defined HTML-Tags by only once call of function. Surely, in PHP4 it would be much
easier to realise such a function - but this function works in PHP3, too. To define the tags that highlight the needle in the hystack-string use an array consisting of two
values [0] (for opening the tag(s)) and [1] (for closing the tag(s)). The function doesn't do any echo's, it only returns the value, so you have to call it in order with echo
to write what it returns.
Some simple functions to handle data for those wanting to write php console scripts with readline, with an example for adding colour to your scripts too.
Purpose?: Useful when you have PHP but no database .... Features: 1) You can sort the table by clicking on the column headers 2) Add new member 3) Update existing member Note:
two pages included in the code example, make sure you split them.
I started playing around with ncurses in PHP with php 4.3.0.rc0 compiled with --with-ncurses and started noticing a huge lack of *any* documentation.. There are a lot of
functions I write which could make good use of the functions as I write a lot of php shell scripts.
I previously wrote up a terminal color function which called perl to do the colorizing. This is more of an update, but is a totally different function. When provided with an
additional variable it will output the colorization versus passing it back as a return variable.
Printer friendly pages from anywhere on a website. This dynamic "Print This Page" script works right out of the box - cut and paste. Has the option to leave images in the new
print friendly page if required. Just link to this script, and it will give a printer friendly version of any page, whether it's a PHP, ASP, CGI, or HTML page. Comes with a
Cascading StyleSheet for further control of your print-friendly pages.
This package performs spell checking of text using only base PHP functions, thus without using specific spell check PHP extensions such as aspell or pspell. The class uses a
dictionary that is implemented as an array-based binary search table. The binary search table declaration is saved to a file for speed and can be updated easily by the
developer.
This simple script picks up random quotes from fortune's-like text files. Sentences are seperated by "%" char, fortune style database. The script could be used with any
textfile, just watch out for the right needle and define()d include dir.
Simple reguler expression test page for both PHP and JavaScript. Now it supports both ereg() and preg_match(). Changed JavaScript test result is look similar to PHP's test
result. (It displays entire matched string for JavaScript RegEx) It will be useful if you want to use the same regular expression to check form values both PHP and Client.
It's probably useful people who are learning regex also.
ROT13 is a useful method of encoding text so that it cannot easily be read. The method originated on USENET, where it was commonly used to hide answers to jokes and spoilers
for forthcoming TV show episodes.
This is just your basic text counter for keeping track of page hit counts. It uses dbm for storing and retrieving its hit counts. This counter does not limit the counting by
IP or anything of the sort, it just increments the counter on a page every time that page is loaded. You can set up a hit count on a page-by-page basis, or have a single
counter for the entire site. Examples are given on usage.
The str class provides 4 perl-like methods for manipulating strings and other scalar variables.
Methods include: pop() - Strip the rightmost character from a string and return the character.
push() - Join one or more scalar values onto the right end of a scalar variable.
The values are concatenated from left to right, in the order that they were specified.
shift() - Strip the leftmost character from a string and return the character.
unshift() - Join one or more scalar values onto the left end of a scalar variable.
The values are concatenated from right to left, in the order that they were specified.
Function created for columnizing larger textblocks faciliating layout. Returns either an array of n number of columns or, if return_formated is set to TRUE, a
preformatted html table with n cells with css_class is returned. Hey... check the commented text for ref =).
This function takes an unformatted US phone number as its only argument then, using regular expressions, determines its validity and formats the number in (XXX) XXX-XXXX
format.
Use zip code ranges for each state to perform a basic STATE/ZIP validation. Designed to go one step beyond checking for a valid state code and a numeric zip code. Catches
additional data entry error without relying on another web site or maintaining a current CITY/STATE/ZIP database. This code currently serves as a pre-edit to a credit card
address verification check. Note: PHP 4 is required to use foreach, but a do-while loop can be substituted to use with PHP 3.
//Returns 0 if two versions are equal. //Returns -1 if $version1 is less than $version2 //Returns 1 if $version1 is greater than $version2 //See strcmp //NOTE: Does not handle
"Beta", "RC", or any other non-numeric version //designation.