PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function mb_str_pad( $input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT) { $diff = strlen( $input ) - mb_strlen( $input ); return str_pad( $input, $pad_length + $diff, $pad_string, $pad_type ); } // assign data to variables $games = [ 'football', 'футбол', // football in russian 'ფეხბურთი', // football in georgian 'хөл бөмбөг', // football in mongolian 'bóng đá' // football in vietnamese ]; // loop through $games array and print rows with built-in str_pad function foreach ($games as $game) { echo str_pad($game, 20) . '|' . PHP_EOL; } echo PHP_EOL . PHP_EOL; // loop through $games array and print rows with custom mb_str_pad function foreach ($games as $game) { echo mb_str_pad($game, 20) . '|' . PHP_EOL; }
Show:  
Copy Clear