Kamis, 25 Juli 2013

PHP Indonesia - Facebook: Mohon bantuan nya mastah,.. Gmana cara cari nilai ...

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. NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Mohon bantuan nya mastah,.. Gmana cara cari nilai ...
Jul 25th 2013, 14:53, by Yessy Vallinen Rasmusholic

Yessy Vallinen Rasmusholic 2:53pm Jul 25
Mohon bantuan nya mastah,..
Gmana cara cari nilai array yg sama dalam sebuah array :
Ilustrasinya gini : $a = array(1,2,3,4,2,5);
Nah, bagaimana saya bisa tahu, jika dalam array di atas ada nilai yg sama,. mohon pencerahannya,..

Anton Wahyu Pramono 3:00pm Jul 25
function array_count_values_of($value, $array) {
$counts = array_count_values($array);
return $counts[$value];
}

Anton Wahyu Pramono 3:00pm Jul 25
googlingnya "count number of occurrences in array php"

Yessy Vallinen Rasmusholic 3:06pm Jul 25
Gmnaa cara penerapan script ni gan Anton Wahyu Pramono :

function array_count_values_of($value, $array) {
$counts = array_count_values($array);
return $counts[$value];
}

mohon pencerahannya, maaf masih newbie,..

Anton Wahyu Pramono 3:08pm Jul 25
echo array_count_values_of(2,$a);

Ruli Armando 3:11pm Jul 25
output yang diinginkan seperti apa?

Yessy Vallinen Rasmusholic 3:13pm Jul 25
Mas Anton Wahyu Pramono : Ooo brarti nilai yg di cek di tentukan dulu ya mas ya, maksud saya gini mas, kita gak perlu menentukan mw ngecek nilai yg mana,...

Mas Ruli Armando : pngennya outputnya gini mas : dia menyatakan kalo angka "2" ada dua buah di dalam array,.. atau angka 2 nya ganda,...

Anton Wahyu Pramono 3:14pm Jul 25
oooo

Anton Wahyu Pramono 3:16pm Jul 25
$counts = array_count_values($a);
lalu di loop setiap nilai di $a di array $counts, kalau ada yang > 2 langsung break loop

Ruli Armando 3:17pm Jul 25
======================
$arr = array(1,2,3,4,2,5);
foreach(array_count_values($arr) as $k => $v){
if($v > 1){
echo $k." ada ".$v." buah di dalam array<br />";
}
}

mungkin gitu, not tested

Yessy Vallinen Rasmusholic 3:19pm Jul 25
Mas Anton Wahyu Pramono : Oke mas, Terima kasih mas anton untuk bantuannya,.. :)

Mas Ruli Armando : Benar banget mas Ruli, terima kasih sangat, pas bgt sperti itu,.. sekali lagi terima kasih Mas Anton dan Mas Ruli,.. :)

Ruli Armando 3:20pm Jul 25
sama2 ya ;)

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