array_reverse を使用せずに、逆の順序で配列を文字列に分解するにはどうすればよいですか?
例えば:
$arrayValue = array(test1, test2, test5, test3);
上記の配列を内破し、出力を次のように取得したいと思います。
テスト3、テスト5、テスト2、テスト1
$str = '';
while (($e = array_pop($arrayValue)) !== null)
$str .= $e.',';
$str = substr($str, 0, -1);
しかし
implode(',', array_reverse($arrayValue))
あらゆる点で優れています。
このような:
$arrayValue = array(test1, test2, test5, test3);
$imploded_array = implode( ',', array_reverse($array_value));
よし、array_reverse なしで:
$imploded_array = '';
for( $i=0; $i<count( $arrayValue ); $i++ ) {
$imploded_array .= $arrayValue[count( $arrayValue ) - $i];
if( $i != count( $arrayValue ) ) $imploded_array .= ', ';
}