Bu kod parçacığı yasal olarak kabul edilir merak ediyordum:
$arr = array(123,456,789,123,456,789);
foreach($arr as $a) {
$arr = $a;
break;
}
//prints 123
echo $arr;
It executes, but are there any pitfalls i should know using this method?
Update: Here is the actual problem
You have an array as follows from the database query (
select * from table where code = $code)
Array
(
[0] => Array
(
[id] => 1
[code] => 1234567
[member_id] => 7
)
[1] => Array
(
[id] => 5
[code] => 1234567
[member_id] =>
)
[2] => Array
(
[id] => 67
[code] => 1234567
[member_id] => 43
)
)
Eğer umurumda tüm (bu kod iddia olduğu anlamına gelir) bir boş member_id olan ilk (varsa) satır bulgudur.
Peki bunu hakkında gidiyor?
Kodlarının dizi tutmak için değişken kullanarak ve sonra istediğiniz satırın ile üzerine yazılmasını Felix Kling göre bunu ne teklif ediyorsun, en iyi çözüm değildir.
Also, bonus credit: How many different 7 digit codes can you generate using 32 characters (duplicate characters allowed)?
o 32 ^ 32 * 7 ya da ((((((32 ^ 32)) 32) ^ 32) ^ 32 ^ ^ 32) ^ 32) ^ 32)?