Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Web Design Pricing Dreamweaver Templates Web Applications Free Tutorials About Contact Us
Services > CSS Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Logo Design Portfolio | Web Design Pricing > Custom Web Design | Logo Design | Business Card Design
Web Design Guide > Website Design w/ Dreamweaver & Fireworks | Fireworks CS4 Cool Features | Photo Effects | Text Effects | Graphic Design Ideas | Web Design Ideas
Website Navigation Ideas | CSS Styles Tutorial | Dreamweaver Template | Server Side Includes | Flash Tutorials > Flash Effects | Flash Sound Button | Sound On/Off Button
Flash Preloader | Import External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

PHP String Functions

In this tutorial you will learn about some common string functions in PHP. This includes:

  1. Length of a string
  2. Splitting the string into an array
  3. Joining array elements into a single string
  4. Repeat the similar string into multiple times
  5. Remove the HTML tags from a string

1. Length of a string

The function 'strlen' is used to return the length of the string that is passed as an argument.

Syntax:

strlen(stringname);

Example:

$string="Baskar";

strlen($string); Output : 6

2. Splitting a string into an array

The function 'explode' is used to split a string into an array using a separator. It takes the separator and the string as its argument.

Syntax:

explode(separator,stringname);

Example:

$string="11-02-2005"

explode("-",$string); Output : 11 in array[0] , 02 in array[1] , 2005 in array[2]

3. Joining the array elements into a single string

The function 'join' is used to join various array elements into a single string. Alternatively 'implode' can also be used to join array elements into a string.

Syntax:

join(separator,arrayname);
(or)
implode(separator,arrayname);

Example:

$arraystring=array("s","baskar","shun");

implode("/",$arraystring); Output : s/baskar/shun

4. Repeating a string 'n' times

The function 'str_repeat' is used to repeat a given string 'n' times. The function takes the string and the number of times to be repeated as its argument.

Syntax:

str_repeat($string,integervalue);

Example:

str_repeat("dd",3); Output : dddddd

5. Remove HTML tags from the string

The function 'strip_tags' is used to remove the HTML tags present in a string by taking the string as its argument.

Syntax:

strip_tags($string);

Example:

strip_tags("Baskar s <br> Name",3); Output : Baskar S Name

That' it you've learnt about some common string functions used in PHP.

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization

Beauty Templates | Business Templates | Christian Templates | CSS Templates | Education Templates | Family Templates | Flash Templates | Free Dreamweaver Templates
Food Templates | General Templates | Government Templates | Health/Medical Templates | Hi-Tech Templates | Kids/Childcare Templates | Low-cost Budget Templates
Personal Templates | Pets Templates | Photography Templates | Profession Templates | Real Estate Templates | Sports Templates | Telecom Templates | Travel Templates
Free Tutorials > Web Design Tutorials | CSS Web Design | Fireworks Tutorials | Dreamweaver Tutorials | Flash Tutorials | SEO Tutorials | Javascript Tutorials | PHP Tutorials