Jump to content

Str_pad not padding


Flic

Recommended Posts

I'm padding out all entries in an array to the same length as the last entry in the array which will always be the longest.Its not working and I'm not sure why, so any help would be appreciated! Its probably something small but I just can't see it.My code:

while ($row = $result->fetch()) {...      $packets = (count($sizes))-1;                      // Count the number of different packet sizes...      $i=0;      $slength = strlen($sizes[$packets]);                // Works out the length of the last entry in sizes      $plength = strlen($prices[$packets]);               // Works out the length of the last entry in prices      while ($i <= $packets){      str_pad($sizes[$i], $slength, STR_PAD_LEFT);        // Pads all packet sizes to the length of the longest one      str_pad($prices[$i], $plength, STR_PAD_LEFT);       // Pads all packet prices to the length of the longest one      $output3[] = '<b>'.$sizes[$i].'</b>      ';      $output3[] = '£'.$prices[$i];      $output3[] = '<input type="radio" name="items" value="'.$sizes[$i].'">';      $output3[] = '<input type="text" name="'.$sizes[$i].'"><br>';      $i++;      }      $output3[] = '</div></div>';}

Thanks!

Link to comment
Share on other sites

For example

$sizes[$i] = str_pad($sizes[$i], $slength, STR_PAD_LEFT);

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...