Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/10685-cant-implode-my-data/
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
Link to comment
https://forums.phpfreaks.com/topic/10685-cant-implode-my-data/#findComment-39870
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.