Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Saturday, 22 September 2012

Import CSV file using PHP

PHP script to import a csv file using fgetcsv() and and a simple foreach loop to display the content in a table.

Friday, 21 September 2012

Extracting email addresses from a text file using PHP REGEX

This is a simple yet effective way to extract email addresses from a .txt file.

The script reads the text file and then uses a REGEX expression to extract the email addresses from the content of the file.

Saturday, 21 July 2012

PHP Language Structure

DATA TYPES

Data types in PHP are generally divided into two categories namely scalar and composite. A scalar variable contains only one value at a time and PHP supports four scalar types:
  1. boolean – can either be true or false.
  2. int – signed (can be positive or negative) numeric integer value.
  3. float – signed floating point value.
  4. string – collection of characters.
Compound data types are essentially containers of other data and PHP supports two types:

Sunday, 4 March 2012

PHP: Variable Handling Functions

  1. debug_zval_dump — Dumps a string representation of an internal zend value to output
  2. doubleval — Alias of floatval
  3. empty — Determine whether a variable is empty
  4. floatval — Get float value of a variable
  5. get_defined_vars — Returns an array of all defined variables
  6. get_resource_type — Returns the resource type
  7. gettype — Get the type of a variable
  8. import_request_variables — Import GET/POST/Cookie variables into the global scope

PHP: Array Related Functions

  1. array_change_key_case — Changes all keys in an array
  2. array_chunk — Split an array into chunks
  3. array_combine — Creates an array by using one array for keys and another for its values
  4. array_count_values — Counts all the values of an array
  5. array_diff_assoc — Computes the difference of arrays with additional index check
  6. array_diff_key — Computes the difference of arrays using keys for comparison
  7. array_diff_uassoc — Computes the difference of arrays with additional index check which is performed by a user supplied callback function
  8. array_diff_ukey — Computes the difference of arrays using a callback function on the keys for comparison

An Introduction to PHP Functions


A function is an input/output “machine”. A function accepts values, processes them and then returns an action.

1. Defining a Function
Functions are defined by using the functions statement :
function someFunction($argument, $argument){

 //function code here

}