• Hi!
    The result of the following script part is: Participant 1, Participant 2, … , Participant n,
    Can you help me to hide last comma?
    Thanks in advance.

    while ( $this->have_records() ) : $this->the_record(); // each record is one row
    while( $this->have_fields() ) : $this->the_field(); // each field is one cell

    echo $this->field->print_value() . ‘, ‘;

    endwhile; // each field
    endwhile; // each record

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The trick I use for this is to place the list into an array, then “implode” the array with the commas.

    
    $display = array();
    while ( $this->have_records() ) : $this->the_record(); // each record is one row
    while( $this->have_fields() ) : $this->the_field(); // each field is one cell
    
    $display[] = $this->field->print_value();
    
    endwhile; // each field
    endwhile; // each record
    
    echo implode( ', ', $display );
    Thread Starter berki

    (@berki)

    Thank you for these. Interestingly, the result is exactly the opposite:

    Participant 1 Participant 2 Participant n,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hide last comma’ is closed to new replies.