<?php $strings = ["v", 'g', 'a']; sort($strings); print_r($strings); ?> This code displays
Array ( [0] => a [1] => g [2] => v ) and how to make it output а, g, v ?
This code displays Array ( [0] => a [1] => g [2...">
instead
print_r ($strings); use
echo join(",",$strings); and yes, sort works))
join is considered "deprecated", code analyzers recommend using implode with the same syntax - Dmitry Kozlov <?php $strings =["v", 'g', 'a']; sort($strings); for($i = 0; $i < count($strings); $i++){ echo $strings[$i]; } ?> As an option using implode ( http://php.net/manual/ru/function.implode.php ):
$strings = ["v", 'g', 'a']; sort($strings); $strings = implode(",", $strings); print_r($strings); Source: https://ru.stackoverflow.com/questions/891716/
All Articles