List files in dir
13
I needed to send an email through an authenticated SMTP server. I found the snippet on the PHP website to do the trick.
16
Format a phone number with php.
4
A simple search array example.
11
Example of how to use CURL with PHP.
23
This snippet originally is used for targetting ads banners depended on the geographic location of the visitor, but can be used for other purposes. Also originally is used for US and the rest of the world, but you can add check for other countries too.
9
Change the case of an array.
14
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.
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
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
This multiple-use PHP script will randomly generate content based on a randomly generated number.
9
This is a simple PHP script that will show whether a certain port/socket of a certain computer is currently open/active.









