note 126364 added to ref.strings

From: Date: Wed, 25 Aug 2021 17:44:03 +0000
Subject: note 126364 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-216825@lists.php.net to get a copy of this message
I'm converting 30 year old code and needed a string TAB function: //tab function similar to TAB used in old BASIC languages //though some of them did not truncate if the string were //longer than the requested position function tab($instring="",$topos=0){ if(strlen($instring)<$topos){ $result=str_pad($instring,$topos-1," ",STR_PAD_RIGHT); }else{ $result=substr($instring,0,$topos-1); } return $result; } $pline="String with this tab to 50 and"; $tline=tab($pline,50)."finish it."; echo $tline.PHP_EOL; $pline="101010101020202020203030303030404040404050505050506060606060"; $tline=tab($pline,50)."finish it."; echo $tline.PHP_EOL; //Results in this output: //String with this tab to 50 and finish it. //1010101010202020202030303030304040404040505050505finish it. ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 71.14.116.81) ---- Manual Page -- https://php.net/manual/en/ref.strings.php Edit -- https://main.php.net/note/edit/126364 Del: integrated -- https://main.php.net/note/delete/126364/integrated Del: useless -- https://main.php.net/note/delete/126364/useless Del: bad code -- https://main.php.net/note/delete/126364/bad+code Del: spam -- https://main.php.net/note/delete/126364/spam Del: non-english -- https://main.php.net/note/delete/126364/non-english Del: in docs -- https://main.php.net/note/delete/126364/in+docs Del: other reasons-- https://main.php.net/note/delete/126364 Reject -- https://main.php.net/note/reject/126364 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216825) next »