PHP Diary | Script School | PHP Scripts | TD Scripts.com
TD Pic of Day PHP - Run your own picture of the day script from any site anywhere with this handy script


[back]
go back 12/28/02 "Handy Built-in PHP Functions" go forward[next]

Did you know these built-in PHP functions were available for use?

Since my last diary entry PHP has made considerable progress. On 12/27/02 PHP 4.3.0 was released and there are plans to put PHP 5.0 in user's hands by mid 2003. Since I started this site a number of useful built-in PHP functions have come out. I'm going to use this particular diary entry to cover some of them and their uses, as well as which version of PHP you need to be using to be able to use them. Keep in mind that you can check what version of PHP you are using by simply using the function phpversion(). Also this list is not intended to be all inclusive. Check the manual for a complete list of functions before sitting down to write your own algorithms. It might save you a whole lot of time and code. Also, I've included at the end (in a separated section) some useful additional php libraries that are available that could be compiled in with your version of PHP.

-- Array functions -- 
Manual Reference:
http://www.php.net/manual/en/ref.array.php
Version: the version number required to be able to use the function

array_count_vals -
http://www.php.net/manual/en/function.array-count-values.php 
version: 4.0 +
Purpose: counts unique values in an array

array_diff - http://www.php.net/manual/en/function.array-diff.php
version: 4.01+ (broken in version 4.04)
Purpose: returns an array containing values that are not present in any of the other arguments. Keys are preserved.

array_rand - http://www.php.net/manual/en/function.array-rand.php   
version: 4.0+ 
Purpose: Pick one or more random entries out of an array

array_sum - http://www.php.net/manual/en/function.array-sum.php 
version: 4.04+
Purpose: returns the sum of values inside an array as an integer or float

array_unique - http://www.php.net/manual/en/function.array-unique.php 
version: 4.01+ (broken in version 4.04)
Purpose: takes input array and returns a new array without duplicate values

-- Image functions --  
Manual Reference: http://www.php.net/manual/en/ref.image.php

getimagesize - http://www.php.net/manual/en/function.getimagesize.php 
version: 3, 4
Purpose: Get the dimensions and file type of an image

-- String functions -- 
Manual Reference: http://www.php.net/manual/en/ref.strings.php

number_format - http://www.php.net/manual/en/function.number-format.php 
version: 3, 4
Purpose: Format a number with grouped thousands like this: 1,000, 10,000, 100,000, 1,000,000

str_word_count - http://www.php.net/manual/en/function.str-word-count.php
version: 4.3.0
Purpose: Return information about words used in a string
alternate regexp for earlier versions: $wordcount = count( preg_split("/[\W]+/", $text) );

wordwrap - http://www.php.net/manual/en/function.wordwrap.php
version: 4.02+
Purpose: Wraps a string to a given number of characters using a string break character.

 

======== The functions below require separate compiling into PHP as of this diary entry======
-- IRC gateway functions -- (to use these functions one must compile ircg support into PHP)
Manual Reference: http://www.php.net/manual/en/ref.ircg.php 
Purpose: to connect to IRC server through PHP scripts
version: 4.04+

New forum for discussion of diary entries

Finally a place to discuss these diary entries, php and other scripting-related stuff. The homeroom at Script School is available to discuss this diary entry. You'll find some recent comments included in these diary entries. You must be an enrolled student at Script School to add comments to these diary entries. Please, no spam, and stay on topic for each diary entry. With this in mind, I'm going to try and start updating these diary entries again more frequently and sharing some useful things I've learned about PHP.

- click here to view comments about this diary entry

Please vote on the usefulness of this diary entry so other people will know if it is worth their time to read :)

How useful was this diary entry? Avg Surfer Rating: 3.27 (105)

[back]go back 12/28/02 "Handy Built-in PHP Functions" go forward[next]

PHP Diary | Script School | PHP Scripts | TD Scripts.com

Copyright 1999-2003 php-scripts Last Modified 02/9/04 11:31