thehigherentity Posted May 29, 2006 Share Posted May 29, 2006 I am useing a foreach loop to collect information for a filethe info is stored as blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blah |~|blah blah blahwithin 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 getWarning: implode(): Bad argumentsI 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 More sharing options...
kenrbnsn Posted May 29, 2006 Share Posted May 29, 2006 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 More sharing options...
thehigherentity Posted May 29, 2006 Author Share Posted May 29, 2006 I never new you could do this[code] <?php $wanted_info[] = $filedata[$col]; ?>[/code]anyway it works, thanks :) Link to comment https://forums.phpfreaks.com/topic/10685-cant-implode-my-data/#findComment-39871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.