logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 10-07-2015, 09:39 PM   #1
jacob1986
 
Join Date: May 2015
Posts: 20
Default php adjust the spacing and line breaks in code

I'm supposed to learn how to adjust the spacing and line breaks in PHP code, but I don't really know where to start? I was given the example below (which I think - I have done correctly). But would it feasble for you to write some jumbled code for me to adjust and show coherently?

<?php
function formstatus ($status)
{
$valid_values = getStatusCodes () ;
if (in_array (strtolower ($status) , $valid_values)) {
return strtolower($status) ;
}
return false;
}

?>
jacob1986 is offline   Reply With Quote
Old 10-07-2015, 11:44 PM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

Have a look at
http://php.net/sprintf

and http://php.net/manual/en/function.str-pad.php
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas

Last edited by edbr; 10-08-2015 at 01:49 AM..
edbr is offline   Reply With Quote
Old 10-08-2015, 02:11 AM   #3
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

couple of examples
Code:
<?php
$num = 'world' ;
$break = '<br> ';

$format = 'There are %s hello in the %s';
echo sprintf($format,  $break,$num );
?>
<br>
<br>

<?php
$str = "Hello World";
echo str_pad($str,60,'.    '.' &nbsp '.' &nbsp '.' &nbsp '.' &nbsp '.' &nbsp '.' &nbsp ' ,STR_PAD_LEFT);
   

?>
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:22 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com