ID: 21582
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: winXP
PHP Version: 4.3.0
New Comment:
bogus then
Previous Comments:
------------------------------------------------------------------------
[2003-01-11 12:00:04] [EMAIL PROTECTED]
sorry, not a bug - array index duplicate :(
------------------------------------------------------------------------
[2003-01-11 11:39:30] [EMAIL PROTECTED]
I have an array. Filter him in foreach cycle. Size of array is 8. Have
a condition if/else - not all part of array come throw
code:
<?php
$info =
unserialize('a:8:{i:100;a:5:{s:2:"id";s:1:"1";s:7:"sponsor";s:1:"1";s:6:"weight";s:3:"100";s:3:"url";s:9:"ahsfd.com";s:4:"html";s:4:"html";}i:200;a:5:{s:2:"id";s:1:"2";s:7:"sponsor";s:1:"1";s:6:"weight";s:3:"200";s:3:"url";s:12:"kilemall.net";s:4:"html";s:4:"html";}i:300;a:5:{s:2:"id";s:1:"3";s:7:"sponsor";s:1:"1";s:6:"weight";s:3:"300";s:3:"url";s:10:"fuck2k.com";s:4:"html";s:4:"html";}i:400;a:5:{s:2:"id";s:1:"4";s:7:"sponsor";s:1:"2";s:6:"weight";s:3:"400";s:3:"url";s:7:"mail.md";s:4:"html";s:4:"html";}i:500;a:5:{s:2:"id";s:1:"5";s:7:"sponsor";s:1:"4";s:6:"weight";s:3:"500";s:3:"url";s:10:"quake3.com";s:4:"html";s:4:"html";}i:600;a:5:{s:2:"id";s:1:"6";s:7:"sponsor";s:1:"4";s:6:"weight";s:3:"600";s:3:"url";s:6:"sex.md";s:4:"html";s:4:"html";}i:700;a:5:{s:2:"id";s:1:"7";s:7:"sponsor";s:1:"5";s:6:"weight";s:3:"700";s:3:"url";s:6:"sex.ru";s:4:"html";s:4:"html";}i:800;a:5:{s:2:"id";s:1:"8";s:7:"sponsor";s:1:"6";s:6:"weight";s:3:"800";s:3:"url";s:7:"sex.net";s:4:"html";s:4:"html";}}');
$cookie = '1|3|5|7|9|11|13|15|17|19|21';
$cookie_br = explode('|', $cookie);
$spid = '';
$info2 = array();
$info_rest = array();
$i=0;
$i_rest=0;
echo "<hr>info <font color=red>".count($info)."</font>";
print_r($info);
foreach ($info as $k=> $line)
{
mt_srand((float)microtime()*1000000);// untill php4.2.0
$weight = mt_rand(1,10)* $line['weight']; // rand
if (!in_array($line['id'], $cookie_br) || ($spid==$line['sponsor']))
{
$info2[$weight] = array('id' =>$line['id'],
'sponsor'=>$line['sponsor'],
'weight' =>$weight,
'url' =>$line['url'],
'html' =>$line['html']);
$i++;//counter
}
else//rest
{
$info_rest[$weight] = array('id' =>$line['id'],
'sponsor'=>$line['sponsor'],
'weight' =>$weight,
'url' =>$line['url'],
'html' =>$line['html']);
$i_rest++;//counter
}
}
echo "<hr>info2 <font color=red>".count($info2)."</font>";
print_r($info2);
echo "<hr>inforest <font color=red>".count($info_rest)."</font> i_rest
".$i_rest;
print_r($info_rest);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21582&edit=1