Zip Codes





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

« Previous 1 2  ...  7 8 9 10 11 12 13 14 15 Next »
14
Date Submitted Wed. Mar. 22nd, 2006 6:10 PM
Revision 2
Beginner nev3rm0re
Tags PHP | String
Comments 1 comments
This function calculates how many lines will text occupy.
Example (simple):


$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus tincidunt posuere dolor";

$num_lines = how_many_lines(10, $string);

It accepts a third, optional, parameter $options, that allows you to change behaviour. $options should be array. Following configuration options are available:

'white_spaces' - default: array(' ', "\t") - array of chars, that should be treated as whitespace.

'new_lines' - default: array("\r\n", "\n") - array of strings, that should be treated as newlines. For example, for HTML you can set 'new_lines' => array('');

'force_line_breaks' - default: true - force wrapping, when the token is longer than width, or not. If set to false, and token cannot be fitted into $width, function will return false;

'callback' - default: null - callback function for determining character width. Must accept at least one parameter - $char

'callback_params' - default: array() - optional additional callback parameters

'char_widths' - default: null - associative array in a form $char => $width, which contains char width. If $char is not found in the array, it's width is defaulted to 0.

7
Date Submitted Wed. Mar. 15th, 2006 12:16 PM
Revision 1
Beginner windley
Tags cloud | movabletype | PHP | tags
Comments 0 comments
This code, working with MovableType, creates a tag cloud of tags entered into the keyword field of a blog entry. You can see the results and read my write-up which explains some other things that help with MovableType and tag clouds. I got this code from Al-Muhajabah and made a few minor tweaks. Put the PHP snippet below inside a MT template that creates a php page.
-5
Date Submitted Sat. Mar. 11th, 2006 7:28 PM
Revision 1
Helper Scriptsentials
Tags "Random Generation" | PHP | Random
Comments 3 comments
This multiple-use PHP script will randomly generate content based on a randomly generated number.
9
Date Submitted Sat. Mar. 11th, 2006 4:52 PM
Revision 1
Helper Scriptsentials
Tags PHP | Ports | Sockets
Comments 0 comments
This is a simple PHP script that will show whether a certain port/socket of a certain computer is currently open/active.
8
Date Submitted Tue. Feb. 21st, 2006 9:50 PM
Revision 2
Coder mattrmiller
Tags PHP | Ping | PingOMatic
Comments 0 comments
Ping, PingOMatic service for an updated. Requires: The Inutio XML-RPC Library.
9
Date Submitted Mon. Feb. 20th, 2006 11:22 AM
Revision 2
Beginner elbartoli
Tags connect | display | mysql | PHP
Comments 1 comments
Connect to MySQL db & display result from Table query
8
Date Submitted Sun. Feb. 19th, 2006 2:27 PM
Revision 2
Coder mattrmiller
Tags PHP | Referrer | Validate
Comments 6 comments
Fixed missing $ sign.
11
Date Submitted Fri. Feb. 17th, 2006 1:14 PM
Revision 1
Coder mattrmiller
Tags "Magic Quotes" | PHP | Slashes | Strip
Comments 1 comments
This only seems appropriate, we were fighting with a similar issue this morning.
-7
Date Submitted Fri. Feb. 17th, 2006 4:52 AM
Revision 3
Helper mercutio
Tags mysql
Comments 0 comments
I use this method for keeping my sql templates away from my code.

You can extend upon the idea, as I have done in the past, by placing SQL handing classes between your scripts and the template library.

Things to note here:

The lesser userd heredoc string method. The reason this is used is to keep the SQL clear and well laid out, and not as messy as using quotes.

vsprintf() is a very handy function if you don't want to hard code the number of parameters to interpolate your string with.

The use of sprintf templates offers you additional security. For example, only allowing numbers to be placed where a %d falls. This, of course, shouldn't be the only security on user supplied variables, but comes in extra handy for debugging purposes.

Regarding the TODO in there, it would take a check of the number of % placeholders there are in the template. One caveat is remembering to remove the count of %%'s that appear (the literal percentage).
7
Date Submitted Mon. Nov. 28th, 2005 4:35 PM
Revision 1
Beginner Michael
Tags Extract | PHP
Comments 3 comments
Using the extract() Functio
« Previous 1 2  ...  7 8 9 10 11 12 13 14 15 Next »