Selasa, 20 Agustus 2013

PHP Indonesia - Facebook: [tanya] : $data = '[{"kode":1,"nama":"mobil","ha...

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/ 
Refresh your vocabulary.

Learn a new word everyday by subscribing to Word of the Day. A great tool if you're studying for the GRE, GMAT or LSAT, or simply want to enhance your lexicon.
From our sponsors
[tanya] : $data = '[{"kode":1,"nama":"mobil","ha...
Aug 12th 2013, 08:10, by Indra Syafi'i

Indra Syafi'i 8:10am Aug 12
[tanya] :
$data = '[{"kode":1,"nama":"mobil","harga":200},{"kode":2,"nama":"motor","harga":100},{"kode":3,"nama":"sepeda","harga":50}]';
foreach ($data as $key => $value) {
echo $value['nama'];
}
error pas di foreach, kenapa yah???
#tolongin #donk

Yopi ى Atria 8:16am Aug 12
ganti var nya
$data = array(
array("kode"=>1,"nama"=>"mobil","harga"=>200),
array("kode"=>2,"nama"=>"motor","harga"=>100),
array("kode"=>":)","nama"=>"sepeda","harga"=>50));

Indra Syafi'i 8:18am Aug 12
itu data kiriman dari ajax JSON.
saya ambil di php pke $data = $_POST['data'];
hasilnya kayak gto.
gimana solusinya mastah? ;)

Amin Erfandy 8:19am Aug 12
$data = json_decode($data)
baru di foreach .

Indra Syafi'i 8:19am Aug 12
hasilnya null...

Yopi ى Atria 8:28am Aug 12
coba
$var_data = (array) json_decode($data);
print_r($var_data);

Bagas Pramudita 8:30am Aug 12
json dulu atuh

Indra Syafi'i 8:32am Aug 12
yopi : error conversi array to string.
bagas : maksudnya gimana mastah?

Ganda Gamaliel Soritua Sinaga 8:35am Aug 12
di decode dulu dari json ke array bro...
$arr_data = json_decode($data);

baru kemudian di foreach :
foreach ($arr_data as $blabla)

Indra Syafi'i 8:40am Aug 12
$arr_data = json_decode($data);
foreach ($arr_data as $key => $value) {
echo $value['nama'];
}
#hasilnya error

Ganda Gamaliel Soritua Sinaga 8:48am Aug 12
itu hasilnya object bro, bukan array, jadi:
$value['nama']
ganti jadi :
$value->nama

Indra Syafi'i 8:50am Aug 12
makasih gan... sukses 100%... (y)

Amin Erfandy 9:08am Aug 12
jika tidak mau objek json_encode($data,true);

Indra Syafi'i 3:18pm Aug 20
Mastah-mastah...
di localhost json_decode jalan 100%.
tapi di hostingan online hasilnya null...
kayaknya ga support json_decode...
ada solusi lain ga?
makasih sebelumnya...
Muhamad Jafar Sidik

Muhamad Jafar Sidik 3:40pm Aug 20
tampilan error nya kaya gmn?

Indra Syafi'i 3:42pm Aug 20
$arr_data = json_encode($data,true);
$arr_data hasilnya null.
sehingga ga bisa di looping.
foreach ($arr_data as $key => $value) {
echo $value['nama'];
}

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