Jump to content

Archived

This topic is now archived and is closed to further replies.

thehigherentity

Cant implode my data?

Recommended Posts

I am useing a foreach loop to collect information for a file

the info is stored as

blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blah

within my loop i have the following

$store .= $filedata[$col]."|~|";

this collects differt info depending on the line. but my problem is when I tryed to implode the $tore it would not work?

this is the code i used to implode
$wanted_info = implode("|~|", $store);

and this is the error i get
Warning: implode(): Bad arguments

I know the info is in $store as i can echo this out and its all fine?

Share this post


Link to post
Share on other sites
The implode() function takes an array and returns a string with the seperater given between each element.
The explode() function takes a string with elements seperated by a string and returns an array.

You're using the wrong function. You want to use the explode() function. But if you're just going to explode the string you just created and put the results into an array, why don't you do that in the first place:
[code]<?php $wanted_info[] = $filedata[$col]; ?>[/code]
If you still want the deliminated string you can create it from the $wanted_info array:
[code]<?php $store = implode('|~|',$wanted_info); ?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.