Jump to content

[SOLVED] Comma Separating


Schlo_50

Recommended Posts

Hi again,

 

I managed to get together this script with the help from the guys here earlier but I am in need of some more help. I have put some strings into an array and now need to separate each string by commas but my implode isnt working. Could someone take a look please?

 

$arrString = array();
$arrString[] = $relevanta;
$arrString[] = $relevantb;
$arrString[] = $relevantc;
$arrString[] = $relevantd;
$arrString[] = $relevante;
$arrString[] = $relevantf;

foreach ($arrString as $v) {
  if (!is_null($v)) {
  $srt_string = implode(",", $v);
  }
}

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/108527-solved-comma-separating/
Share on other sites

Try this, and check if this is what you need

 

$arrString = array();
if(!is_null($relevanta))
$arrString[] = $relevanta;
if(!is_null($relevantb))
$arrString[] = $relevantb;
if(!is_null($relevantc))
$arrString[] = $relevantc;
if(!is_null($relevantd))
$arrString[] = $relevantd;
if(!is_null($relevante))
$arrString[] = $relevante;
if(!is_null($relevantf))
$arrString[] = $relevantf;

$srt_string = implode(",", $arrString);

Archived

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

×
×
  • 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.