Jumat, 09 Agustus 2013

PHP Indonesia - Facebook: [TANYA] saya mau addslahes array value yang ada si...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
[TANYA] saya mau addslahes array value yang ada si...
Aug 9th 2013, 07:44, by Mohamad Wildannudin

Mohamad Wildannudin 7:44am Aug 9
[TANYA] saya mau addslahes array value yang ada single quotenya, kemudian di implode, saya sudah bisa. codenya jalan sesuai harapan, tpi kira2 logika yg lebih sederhananya gimana ya, biar codenya lebih ringkas. (saya coba escape string tiga)
$tes=array('satu','dua','tiga\'');
$im=implode(", ", $tes);
$slash=addslashes($im);
$exp=explode(', ', $slash);
$akhir=implode("', '", $exp);
echo "insert into tes values ('$akhir')";

Gunawan Mujur Wibisono 7:49am Aug 9
$akhir=addslashes(implode("', '", $exp));
echo "insert into tes values ('$akhir')";

Mohamad Wildannudin 7:53am Aug 9
masih variable $exp or $tes?

Gunawan Mujur Wibisono 7:54am Aug 9
ralat.. $exp ganti $tes

Mohamad Wildannudin 7:54am Aug 9
hasilnya ga sesuai kalau gitu, insert into tes values ('satu\', \'dua\', \'tiga\'') harusnya insert into tes values ('satu', 'dua', 'tiga\'')

Gunawan Mujur Wibisono 8:00am Aug 9
bagaimana kl begini
foreach($tes as $i=>$v)
{
$tes[i]=addslashes($v);
}
$akhir= implode("', '", $tes) ;
echo "insert into tes values ('$akhir')";

Mohamad Wildannudin 8:02am Aug 9
perfect, thanks mas Gunawan Mujur Wibisono

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar