1111. appearing after print sequence - php -


morning,

i have code takes string of shoe sizes, explodes , puts in table. code works , info displayed correctly on page after table there few 1's after table. i'm confused this.

so table looks (in columns of 3 on webpage)

available in following sizes: 3 4 5 6 9 10

111

here's codes, purpose of example $x = 3|4|6|10|9

function get_sizes_pipe($x) {  $counter = 0; $splits = explode("|",$x); asort($splits);  $x = print "<table class='greentable'>";  $x .= print "<thead><tr><th scope='col' colspan='3' abbr='starter'>available in following sizes:</th></tr></thead><tbody><tr>";  foreach ($splits $split) {     $entry = print "<td>".$split."</td>";      if($counter == 2){         $entry .= print "</tr><tr>";         $counter =0;     } else {      $counter++;      }  }  if($counter == 1){     $entry .= print "<td></td><td></td>"; }elseif ($counter == 2) {     $entry .= print "<td></td>"; }  $x.= $entry;  $x.= print "</tr></tbody></table>";  return $x;  } 

i'd appreciate help.

thanks chris

try this:do not use print appending $x echo $x;

 <?php function get_sizes_pipe($x) {  $counter = 0; $splits = explode("|",$x); asort($splits);  $x =  "<table class='greentable'>";  $x .= "<thead><tr><th scope='col' colspan='3' abbr='starter'>available in following sizes:</th></tr></thead><tbody><tr>";  foreach ($splits $split) {     $entry .= "<td>".$split."</td>";//use . concate here      if($counter == 2){         $entry .= "</tr><tr>";         $counter =0;     } else {      $counter++;      }  }  if($counter == 1){     $entry .="<td></td><td></td>"; }elseif ($counter == 2) {     $entry .=  "<td></td>"; }  $x.= $entry;  $x.="</tr></tbody></table>";  echo $x;  }  get_sizes_pipe("1|2|3|4"); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -