i have 2 foreach loops, they both loop through the same array; however one loops through the array after str_replace is used, while the other does not use str_replace;
my problem; how do i coordinate these 2 loops so that they will loop through the same array at the same time?
sorry if my problem is not as descriptive;
$contents = ftp_nlist($conn_id, $dir);
$unalteredcontents = ftp_nlist($conn_id, $dir);
foreach ($unalteredcontents as $fname2)
{
if (($fname2 != '.') && ($fname2 != '..'))
{
$url = "http://mywebsite.com/folder/" . $userid . "/" . $fname2 . "";
next($fname2);
}
}
$contents = str_replace("-", '', $contents);
$contents = str_replace(".pdf", '', $contents);
foreach ($contents as $fname)
{
if (($fname != '.') && ($fname != '..'))
{
$sql_select = "INSERT INTO `database`.`column` (`data`, `fileurl`) VALUES ('" . $fname . "', '" . $url . "') ";
}
}
Something like this: