implode() function help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

implode() function help

Post by Monotoko »

Hiya :)

i have this script:

Code: Select all

<?php
$dirarray = (scandir("../../"));
$startcount = 2;
$countall = count($dirarray);
 
while ($startcount != $countall)
{
 
$filename = "../../".$dirarray[$startcount]."/pubstermx/inc/pubsterdomainconfig.php";
$homepage = "../../".$dirarray[$startcount]."/index.php";
if (file_exists($filename))
{
if (file_exists($homepage))
{
$tempfile = file($homepage);
$counttemp = count($tempfile);
unset($tempfile[$counttemp -1]);
print_r ($tempfile);
}
 
}
$startcount++;
}
 
?>
Now that works well, it gets the file index.php into the array successfully, takes the bottom line off, and prints it, but when i replace
line #

with:

Code: Select all

echo implode(" ",$tempfile);
in order to turn it into a string...i get nothing

Am i missing something in the implode function? Should i be using something else to put the array into the file?

~Daniel
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: implode() function help

Post by jackpf »

Hmm...your code looks fine. Try using var_dump() instead of echo...see what that returns.
Post Reply