roonnyy Posted December 9, 2009 Share Posted December 9, 2009 Hi guys, I've got php function which puts 2 white space after every character in string for example: HELLO to H E L O I can't use HTML characters like ' ' (I need only white spaces between words) because I print this into PDF with FPDF and FPDF print H  E  ..... Any ideas? I'll apreciate any help. Thanks Link to comment https://forums.phpfreaks.com/topic/184530-whitespace/ Share on other sites More sharing options...
phant0m Posted December 9, 2009 Share Posted December 9, 2009 use <pre></pre> around your text Link to comment https://forums.phpfreaks.com/topic/184530-whitespace/#findComment-974153 Share on other sites More sharing options...
roonnyy Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks for fast reply but I can't use HTML characters because of PDF generator (FPDF) it will print HTML characters like normal text Link to comment https://forums.phpfreaks.com/topic/184530-whitespace/#findComment-974155 Share on other sites More sharing options...
mrMarcus Posted December 9, 2009 Share Posted December 9, 2009 simple little function: <?php function add_spaces ($str) { $len = strlen ($str); //string length; $c = 1; //counter to keep trailing spaces form being appended; for ($i=0; $i<$len; $i++) { if ($c == $len) { $n_str .= substr ($str, $i, 1); } else { $n_str .= substr ($str, $i, 1). ' '; } $c++; //increment; } return $n_str; } echo add_spaces ('hello'); //prints h e l l o; ?> Link to comment https://forums.phpfreaks.com/topic/184530-whitespace/#findComment-974177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.