Zend - The PHP Company




Text

Add Code


"Barcode" (query)string  

Type: code fragment
Added by: bigmweb
Entered: 18/01/2001
Last modified: 01/12/2000
Rating: **** (9 votes)
Views: 14698
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.


Add Slashes to all form data fields  

Type: code fragment
Added by: mworld
Entered: 10/08/2000
Last modified: 08/12/1999
Rating: *** (5 votes)
Views: 7838
Add Slashes to all fields submitted from a form. You could also run other functions over the fields.


Akelos PHP Inflector  

Type: class
Added by: akelosmedia
Entered: 15/01/2006
Last modified: 02/12/2005
Rating: - (fewer than 3 votes)
Views: 8700
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.


Alternative Zip Code Checker  

Type: code fragment
Added by: rmullen
Entered: 24/03/2005
Last modified: 03/12/2004
Rating: - (fewer than 3 votes)
Views: 4004
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.


Case insensitive str_replace  

Type: code fragment
Added by: stevo_x
Entered: 29/10/2002
Last modified: 09/12/2008
Rating: **** (3 votes)
Views: 6353
This function returns a string with all occurences of search in subject replaced with the given replace value.


Check for truly blank strings  

Type: code fragment
Added by: marcus1
Entered: 16/07/2000
Last modified: 08/12/1999
Rating: ** (6 votes)
Views: 6955
isBlank is a function to determine if a string is really empty or not.


Cleanup Function  

Type: code fragment
Added by: RzE
Entered: 14/01/2001
Last modified: 04/12/2000
Rating: - (fewer than 3 votes)
Views: 7320
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.


Convert \r\n to \n, can be Global Search & Replace  

Type: code fragment
Added by: magnet
Entered: 29/04/2001
Last modified: 05/12/2000
Rating: - (fewer than 3 votes)
Views: 6578
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.


Cutting long sized text with 'explode'  

Type: code fragment
Added by: u2love
Entered: 02/03/2000
Last modified: 08/12/1999
Rating: *** (9 votes)
Views: 9415
Cutting long size string


Dictionary.com interface  

Type: code fragment
Added by: amars
Entered: 26/04/2002
Last modified: 05/12/2001
Rating: - (fewer than 3 votes)
Views: 5476
Adds the ability to flag a keyword so that it presents a link to it's definition.


Easy TextWrapper  

Type: code fragment
Added by: Coddy
Entered: 26/07/2000
Last modified: 08/12/1999
Rating: **** (4 votes)
Views: 7829
Wrap text for e.g. textmails with a 72 wrap.


Enable e-mail and web addresses in a string  

Type: code fragment
Added by: russlndr
Entered: 21/12/2000
Last modified: 07/12/2000
Rating: **** (12 votes)
Views: 10088
This function add HTML code to all urls in a string and return the string with clickable urls.


English dictionary with Soundex & Metaphone values  

Type: code fragment
Added by: tapolyai
Entered: 06/09/2001
Last modified: 09/12/2000
Rating: **** (3 votes)
Views: 5596
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.


Filter  

Type: class
Added by: zak
Entered: 27/05/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 7225
A simple class that lets you use multiple functions to create custom filters.


format_page  

Type: class
Added by: flight553
Entered: 28/09/2000
Last modified: 01/12/2000
Rating: **** (3 votes)
Views: 6435
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.


FUNCION PRINTFV (PRINT text with Format from a Variable)  

Type: application
Added by: Donatien
Entered: 25/01/2001
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 5043
This function prints out the contents of a varible replacing control codes ( \" \n \\ ) just like printf() does with a string literal.


Global Search And Replace  

Type: code fragment
Added by: RLYNCH
Entered: 02/02/2000
Last modified: 08/12/1999
Rating: *** (3 votes)
Views: 8943
Globally Searches and Replaces text in files throughout a directory.


Highlight  

Type: code fragment
Added by: Souldrinker
Entered: 10/08/2001
Last modified: 08/12/2000
Rating: - (fewer than 3 votes)
Views: 5472
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.


highlight  

Type: code fragment
Added by: stevo_x
Entered: 30/10/2002
Last modified: 01/11/2001
Rating: - (fewer than 3 votes)
Views: 4440
This Function allows to highlight assigned case insensitive Parts (search) of a string (subject) with pre defined HTML-Tags


IconCounter  

Type: application
Added by: iwyrobi
Entered: 03/02/2001
Last modified: 01/12/2003
Rating: - (fewer than 3 votes)
Views: 6130
a very simple text counter but with an icon


Implementing PHP into console with readline  

Type: code fragment
Added by: phpie
Entered: 17/02/2002
Last modified: 03/12/2001
Rating: - (fewer than 3 votes)
Views: 4857
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.


List all 256 Character Function  

Type: code fragment
Added by: madlogic
Entered: 30/11/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 5055
This will return all the 256 characters with its valid char('value'); ...


Member register without database  

Type: application
Added by: Jilette
Entered: 09/01/2002
Last modified: 01/12/2001
Rating: - (fewer than 3 votes)
Views: 7090
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.


ncurses examples (plus undocumented)  

Type: application
Added by: joeldg
Entered: 15/12/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 5056
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.


New Terminal color function  

Type: application
Added by: joeldg
Entered: 13/12/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 5360
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.


Phone-Number-Checker  

Type: code fragment
Added by: ThB
Entered: 13/06/2001
Last modified: 06/12/2000
Rating: - (fewer than 3 votes)
Views: 8040
Breaks a phone number string into country code, city code, number and dial trough. Takes many different formats.


PHPrint - "Print this Page" script  

Type: application
Added by: garrotte
Entered: 31/07/2002
Last modified: 08/12/2001
Rating: ***** (3 votes)
Views: 26632
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.


Pure PHP Spell Check  

Type: class
Added by: jeffwelch
Entered: 19/07/2005
Last modified: 02/12/2005
Rating: - (fewer than 3 votes)
Views: 6124
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.


Quote from fortune  

Type: code fragment
Added by: fath
Entered: 26/12/2001
Last modified: 01/12/2001
Rating: - (fewer than 3 votes)
Views: 4506
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.


Random Name Generator  

Type: application
Added by: weeder
Entered: 29/09/2000
Last modified: 09/12/2002
Rating: - (fewer than 3 votes)
Views: 11605
As the title implies, this is a random name generator, ported to PHP by me, was originally in C.


Random Text Quote  

Type: code fragment
Added by: Lysander
Entered: 12/10/2002
Last modified: 31/10/2001
Rating: - (fewer than 3 votes)
Views: 4544
Chooses a random line of text from a list and displays it.


Reguler Expression Test Page  

Type: application
Added by: yohgaki
Entered: 12/02/2001
Last modified: 04/12/2000
Rating: - (fewer than 3 votes)
Views: 12357
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.


replacestring (new)  

Type: code fragment
Added by: stevo_x
Entered: 30/10/2002
Last modified: 01/11/2001
Rating: - (fewer than 3 votes)
Views: 4064
This function returns a string with all occurences of search in subject replaced with the given replace value.


ROT13 Encoding Function  

Type: code fragment
Added by: brettb
Entered: 17/07/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 5881
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.


SetFile class, ini-like settings class  

Type: class
Added by: S5o
Entered: 05/11/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 5239
Provides a simple ini-type settings file interface. Great for saving and reading variables quick between executions.


Show the difference between text.  

Type: class library
Added by: vini
Entered: 01/07/2004
Last modified: 31/10/2003
Rating: - (fewer than 3 votes)
Views: 6038
This text utility will allow user to pass two slightly changed texts and will display block of text with the differences in this text


Simple counter  

Type: application
Added by: ras78
Entered: 05/02/2002
Last modified: 02/12/2001
Rating: - (fewer than 3 votes)
Views: 4476
Extreme easy counter example. Create a text file wich store the hits.


Simple Text Counter using DBM  

Type: class
Added by: morrison
Entered: 08/04/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 6807
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.


sow() function  

Type: code fragment
Added by: Rival7
Entered: 01/08/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 4890
The sow() function inserts a string into another string every given increment.


STR - a Perl-like string manipulator class  

Type: class
Added by: zak
Entered: 24/11/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 6987
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.


StringCleanUp Function  

Type: code fragment
Added by: UliPahlke
Entered: 02/05/2001
Last modified: 05/12/2000
Rating: - (fewer than 3 votes)
Views: 5604
CleanUp strings (textfields, textareas)


strip_extension  

Type: code fragment
Added by: deekayen2
Entered: 31/10/2001
Last modified: 01/11/2000
Rating: - (fewer than 3 votes)
Views: 4370
Strip the file extension from a filename.


Text Wrapper  

Type: code fragment
Added by: marcus1
Entered: 16/07/2000
Last modified: 08/12/1999
Rating: **** (4 votes)
Views: 6114
wrap_text is a function to wrap a given text argument to a certain number of characters. It works best with unformatted text.


Text wrapper with regexp  

Type: code fragment
Added by: fabricet
Entered: 24/07/2000
Last modified: 01/12/2001
Rating: **** (3 votes)
Views: 5493
wrap_text is a basic function to wrap a given text argument to a certain number of characters. To be customized.


text2columns  

Type: code fragment
Added by: buffaloBuff
Entered: 30/01/2002
Last modified: 02/12/2001
Rating: - (fewer than 3 votes)
Views: 4689
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 =).


Validate and Format US Phone Numbers  

Type: code fragment
Added by: elixer
Entered: 02/03/2000
Last modified: 08/12/1999
Rating: **** (6 votes)
Views: 10574
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.


Validate Zip Code to State  

Type: code fragment
Added by: jasonthoma
Entered: 14/08/2002
Last modified: 08/12/2001
Rating: ***** (5 votes)
Views: 17906
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.


ValidatePhoneNumber  

Type: code fragment
Added by: shrub
Entered: 23/04/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 6048
This is a bug-fix to elixer's version. The first digit of the area code and prefix cannot be 0 or 1.


versioncmp  

Type: code fragment
Added by: RLYNCH
Entered: 21/06/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 4893
//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.



Search



This Category All Categories