Wednesday 15 August 2012

Day 2/10 learn PHP in 10 days - PHP String and Array Functions

Today we are going to learn about strings and arrays in PHP. String and array functions are really handy in handling input and output data to manipulate it accordingly.

Some Basic String Functions in PHP


Some of the basic functions available in PHP to handle string are as under, We are not going to discuss anything in detail, you can try searching it online or see PHP manual.
  1. str_replace() to find and replace data in a string
  2. strpos() find the position of the character/string within a string. 
  3. ucwords() to make first letter capital 
  4. strtolower() php function to lowercase the TEXT/STRING
  5. substr() find portion of a string.
  6. explode() This functions make pieces of a string with respect to any characters/string
 You can find details about these super-useable and easy to understand php string function from php.net manual.

Some Basic Array Functions in PHP

Here are some basic array manipulation functions in PHP
  1. array() this is to create a new array like $names= array("name1","name2","name3");
  2. count() This functions returns number of entries in an array
  3. sort() sorts an array
  4. in_array() checks if a values is present in an array
 There are many more array functions you can read from http://php.net/manual/en/ref.array.php


No comments:

Post a Comment