There are several ways to do this, some of which have given. implode(), join(), var_export(), print_r(), serialize(), json_encode() exc ... You can also write your own function without them:
Cycle
A For() very useful. You can add the value of your array to the following variable:
<?php $dizi=array('mother','father','child'); //This is array $sayi=count($dizi); for ($i=0; $i<$sayi; $i++) { $dizin.=("'$dizi[$i]',"); //Now it is string... } echo substr($dizin,0,-1); //Write it like string :D ?>
In this code, we added the values ββof $ dizi and a comma to $ dizin:
$dizin.=("'$dizi[$i]',");
Now
$dizin = 'mother', 'father', 'child',
This is a string, but it contains an extra comma :)
And then we removed the last comma, substr($dizin, 0, -1);
Output:
'mother', 'father', 'child'
BARIS KURT Dec 03 '15 at 23:14 2015-12-03 23:14
source share