 |
GlobalWeb.com.ru Free Web Hosting :: Commercial Web Hosting :: PHP/mySQL :: CGI/Perl
|
|
|
| Author |
Message |
popinho
Joined: 12 Mar 2004 Posts: 51 Location: Austria
|
Posted: Thu Apr 01, 2004 7:56 am Post subject: function: explode() / implode() |
|
|
Function: explode()
Syntax:
| Code: |
<?PHP
explode(separator, string [, limit])
?>
|
Description:
With explode() you divide a string on a pre-defined seperator. The last parameter is optional and only limits the maximum of the result-array. All elemnts of the string will be saved in an array.
Example:
| Code: |
<?PHP
$string = "¾ apples, bananas²";
echo $string;
echo "<br>";
$array = explode(" ",$string);
for($x=0;$x<count($array);$x++){
echo $array[$x];
}
?>
|
Output:
| Code: |
¾ apples, bananas²
3/4apples,bananas2
|
Also see:
|
|
| Back to top |
|
 |
popinho
Joined: 12 Mar 2004 Posts: 51 Location: Austria
|
Posted: Thu Apr 01, 2004 8:05 am Post subject: |
|
|
Function: implode()
Syntax:
| Code: |
<?PHP
implode(glue, pieces)
?>
|
Description:
With implode() you add an array (pieces) with a seperator (glue) to a string together.
Example:
| Code: |
<?PHP
$array = array("3/4","apples,","bananas²");
echo implode(" ",$array);
echo "<br>";
echo implode("",$array);
echo "<br>";
echo implode("#",$array);
?>
|
Output:
| Code: |
¾ apples, bananas²
3/4apples,bananas²
3/4#apples,#bananas²
|
|
|
| Back to top |
|
 |
|
|