fpdf – PHP Mysql – How to control white space after every number-ThrowExceptions

Exception or error:

I have this code below, How would I do it if I want to control the spacing between the numbers.
1 0 , 5 6 5 , 6 6 0 . 8 8 ( currently 1 white space ) – This is the current output, I want more
spaces between every numbers maybe 3 or more white space. Thank you in advance.

 <?php session_start() ; ?>
 <?php require "../db_connection304.php" ; ?>
 <?php


 require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
 require_once('../../bus_partners/fpdf/fpdi/fpdi.php');


 $pdf = new FPDI();



 if (isset($_POST["submit"])) {


         $payroll_month  = mysqli_real_escape_string($connection304, $_POST['payroll_month']);


             }

         $year  =  preg_split("/[-_ ]+/", $payroll_month) ;
         $year  =  $year[1] ;

         $payrolldate1      = str_replace('_','', $payroll_month) ;
         $payroll_date2     = date_create_from_format("FjY","$payrolldate1") ;
         $monthly_statutory = date_format($payroll_date2,"m") ;


 $query             = "SELECT SUM( GROSS_PAY ) AS gross_pay FROM ".$_SESSION['$company_code']."_".$year." WHERE MONTH(PAYROLL_PERIOD) = '{$monthly_statutory}' ";
 $result_gross_pay    = mysqli_query($connection304,$query) ; 
 while($row_gross_pay = mysqli_fetch_array($result_gross_pay))  { 


         $gross_pay    = $row_gross_pay['gross_pay'] ;


             }


$gross_pay              =  number_format($gross_pay,2 ) ;
$gross_pay_withspace    =  chunk_split($gross_pay,1,' ') ;
How to solve:

replace

chunk_split($gross_pay,1,' ') ;

with

chunk_split($gross_pay,1,"&nbsp;&nbsp;&nbsp;") ;
//no. of "&nbsp;" varies based on requirement

Leave a Reply

Your email address will not be published. Required fields are marked *