giba Posted November 18, 2009 Share Posted November 18, 2009 Hi there, everybody. I am with a situation here. I must export some datas to a specific program written in Java and this program needs to import the datas counting the characters for with field, this way, I need to insert white spaces fo fullfill a count of characters. See the example below for a student: ID = 6 chars NAME = 30 chars AGE = 2 chars FATHERNAME = 30 chars MOTHERNAME = 30 chars In this case, if I have to export JOHN WHITE, ID 123456, 10 YEARS OLD, son of GILBERT WHITE and JANET WHITE: I must have: 6 chars 30 2 30 30 ______________________________________________________________________________ | | | | |<-ends here 123456JOHN WHITE 10GILBERT WHITE JANETE WHITE Is there a function for solving this, or some logic way to get it? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/181940-solved-insert-whitespaces-to-fullfill-a-count-of-characters/ Share on other sites More sharing options...
Garethp Posted November 18, 2009 Share Posted November 18, 2009 $Str = str_pad($Str, 30); That pads $Str to 30 characters, using whitespace on the end Link to comment https://forums.phpfreaks.com/topic/181940-solved-insert-whitespaces-to-fullfill-a-count-of-characters/#findComment-959676 Share on other sites More sharing options...
giba Posted November 18, 2009 Author Share Posted November 18, 2009 $Str = str_pad($Str, 30); That pads $Str to 30 characters, using whitespace on the end Thank you! That's what I am needing! Link to comment https://forums.phpfreaks.com/topic/181940-solved-insert-whitespaces-to-fullfill-a-count-of-characters/#findComment-959722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.