Jump to content

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);

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.