Jump to content

Dealing with whitespace


Massacres

Recommended Posts

Using my knowledge of C/C++ (which is basic) I came up with this, I don't know a way to deal with the whole "We don't want whitespace so we WILL NOT LET YOU HAVE white space", 'thing'. I think it was for bandwidth, some programmers wouldn't get rid of whitespace and it would send useless bits; I want those 'useless' bits. (Sorry my history is a little sketchy).

[code]<?php
for ($i=1; $i<101;$i++){
      echo $i," ";
      if ($i % 5 === 0) {
            echo "<br>";
            }
      else{
            if ($i<10){
                  echo " ";
                  }
            }
      }
?>[/code]

Basically I WANT the whitespace so I can make everything even; without tables.
Link to comment
https://forums.phpfreaks.com/topic/28057-dealing-with-whitespace/
Share on other sites

EDIT: it didn't work; see the bottem.

Ideal situation; the underscores removed and replaced with spaces.

[code]<?php
for ($i=1; $i<101;$i++){
      if ($i<10){
            echo "_";
            }
      echo "_",$i;
      if ($i % 5 === 0) {
            echo "<br>";
            }
      else{
            echo "_";
            }
      }
?>[/code]






Code that didn't work T_T
[code]<?php
for ($i=1; $i<101;$i++){
      if ($i<10){
            echo "&nbsp;";
            }
      echo "&nbsp;",$i;
      if ($i % 5 === 0) {
            echo "<br>";
            }
      else{
            echo "&nbsp;";
            }
      }
?>[/code]

EDIT It works now haha, wow I'm blind sorry.

[code]<?php
for ($i=1; $i<101;$i++){
      if ($i<10){
            echo "&nbsp;","&nbsp;";
            }
      echo $i;
      if ($i % 5 === 0) {
            echo "<br>";
            }
      else{
            echo "&nbsp;";
            }
      }
?>[/code]

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.