Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads | All Downloads

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Swish Templates
   SWiSH Climax
   GimpTalk
   Idea Designs
   Sposatoettore
   Try Acai Berry Diet
   Download Free Ringtones
   Swishzone

Manage your site with Flax Article Content Management System
Functions explode(), implode() [tutorial], useful php functions
Category : PHP / MySQL | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

EXPLODE

function explode() is used to split a string into pieces.
Cutting of the string depending upon a substring or a single character, and returns the chunked form of the string as an array.

For example you have a string

$text="Ali,Jeff,Joel,Cortex,Charly";

now you want to make each name as element of array and access it individually

so what you do:

$arr = explode(",", $text);

means : we have made pieces of string $text based on seperator ','
and put the resulting array in variable $arr

so now $arr contains data as shown following,
By the way the following result can be generated by using print_r() fucntion, which prints out the actual structure of data cotnained in a variable.

So I used print_r($arr); and results are following

Array(
[0] => Ali
[1] => Jeff
[2] => Joel
[3] => Cortex
[4] => Charly
)

which is equal to

$arr = Array("Ali","Jeff","Joel","Cortex","Charly");



IMPLODE

function implode() is oppisite to the explode function. It rejoins any array elements and returns the resulting string, which may be put in a variable.


Take the same example we had above

Your have an array
$arr = Array("Ali","Jeff","Joel","Cortex","Charly");


and you wish to combine it in a string, by putting a seperator '/' between each element of the array.

how to do that?

answer:
$str = implode("/",$arr);

so your resulting string varialbe $str will be containg
Ali/Jeff/Joel/Cortex/Charly

which may be presented in php code as
$str="Ali/Jeff/Joel/Cortex/Charly";


I hope it helps please reply back, if you need more help on it.


All rights reserved - swish-db.com