View Full Version : PHP: Help with explode ect ect.
Luckyrare
23-02-2006, 11:54 PM
Hey guys I am looking for some help for my user system pips
Okay this is what I have writen
$one = 'pipone.gif|piptwo.gif|pipthree.gif|pipfour.gif';
explode('|', $one);
$two = array("$one");
reset($two);
while (list(, $three) = each($two)) {
echo "<img src='$three' />";
}
this is simply outputing a dead image that is called "pipone.gif|piptwo.gif|pipthree.gif|pipfour.gif" so I guess the explode has been used wrong?
Thanks guys,
Danny
Raremandan
24-02-2006, 12:01 AM
Well it looks to me like you are using explode correctly but if I understand correctly do you not have to echo $one like:
explode('|', $one);
echo '$one';
I've never really needed to use explode so I may be wrong.
Luckyrare
24-02-2006, 08:34 AM
No that will just print the arrays with an image. ;) Thanks for your idea anyway
yo dan
mat64 (Forum moderator) - Please don't post pointless messages.
Splinter
24-02-2006, 09:56 AM
as I understand it the explode() command returns an array of a split string so you dont need to use an array()...
for example..
$line = "Hello|World|1|Dog";
$explode = explode("|", $line);
echo $explode[0]; //Would echo Hello
echo $explode[1]; //Would echo World
echo $explode[2]; //Would echo 1
echo $explode[3]; //Would echo Dog
Luckyrare
24-02-2006, 10:16 AM
mmmm, is there any better way of doing this so I can have as many arrays/pips as I want but without having to number them.
Thanks,
Raremandan
24-02-2006, 10:25 AM
I thought as Splinter said you had to echo them I was just not sure in which way.
Luckyrare
24-02-2006, 10:33 AM
ah yes spliter that will work for me. I would rep you but I cant ;)
Thanks dude
closed ;)
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.