note 40285 added to function.explode
| From: | nihaopaul at rn2 dot php dot net | Date: | Fri, 27 Feb 2004 13:19:17 +0000 |
| Subject: | note 40285 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65881@lists.php.net to get a copy of this message | ||
question:
as in the example:
<?php
// Example 1
$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
?>
this doesn't work if you have more spaces in the string...
i.e
<?php
exec('df -h | grep usr', $diskspace);
$tiral_diskspace = $diskspace[0];
echo $tiral_diskspace."<br>";
$disk_space = explode(" ", $tiral_diskspace);
echo $disk_space[12]; //was going to us this for a fix to get the variable i wanted but then thought
twice
?>
output would be something like:
/dev/ad0s2f 1044394 602704 358140 63% /usr
what would i use then to filter out doubles spaces?
Paul
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40285
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40285&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40285&report=yes
Search -- http://master.php.net/manage/user-notes.php