mysql - PHP array into one string -
i have 1 array filled mysql_query. values in array want put 1 continuous string example:
$array = array(1, 2, 3, 4, 5); insert 'new_slovmas'.'$tabulka'('$array[0]', '$array[1]', '$array[3]') values ('$r_1', '$r_2', '$r_3')";
sense in 1 table on 50 columns not want fill manually, while or for. thinking putting values 1 string this:
$array = array("'1',", "'2',", "'3',", "'4',", "'5',");
so have this:
echo $array[2]; => '3',
by cycle wont achieve having multiple entries in 1 variable.
$str = $array[0], $array[1] ... $array[xy]; insert 'new_slovmas'.'$tabulka'('$str') values ('$r_1', '$r_2', '$r_3')";
use implode()
$string = implode(',', array(1, 2, 3, 4, 5)); // $string = 1,2,3,4,5
Comments
Post a Comment