I'm having a problem extracting data from a text file. I imploded a series of arrays and wrote them to a text file. The code I'm using is:
$fname = $_SESSION["fname"];
$lname = $_SESSION["lname"];
$name = array($fname,$lname);
$fullname = implode(' ', $name);
The result:
fname1 lname1fname2 lname2fname3 lname4fname5 ...
Unfortunately, I can't extract the data correctly because there is no space between the 2nd and 3rd values, (lname1fname2 should be lname1 fname2), 3rd and 4th values, etc.
First I used a space (' ' vs. '') as the glue then I tried using a comma (,) but they don't affect the end of each entry. I noticed something in the manual about an implode function with an outerglue:
function implode_assoc($inner_glue,$outer_glue,$array,$skip_empty=false){
$output=array();
foreach($array as $key=>$item)
if(!$skip_empty || $item){$output[]=$key.$inner_glue.$item;}
return implode($outer_glue,$output);
}
but there's no function for how to explode this. How can I resolve this?