Reply to PHP seems to be ambiguous: which result is correct ?

Your name:

Reply:


Posted by Osiris on 12/02/07 11:09

Now for the really kinky thing: running the following routine on my
localhost(apache 2.2.3,PHP5), I get
2 2 2 2 2 2
2 1 1 1 1 1
2 2 1 1 1 1
2 2 2 1 1 1
2 2 2 2 1 1
2 2 2 2 2 1
Running it through the Eclipse PHP Zend debugger I get (which, in my
opinion, is right):
2 4 4 4 4 4
4 2 4 4 4 4
4 4 2 4 4 4
4 4 4 2 4 4
4 4 4 4 2 4
4 4 4 4 4 2

<?php
$k = array(1=> // upper triangular matrix of 1's
array(1=>1,1,1,1,1,1),
array(2=>1,1,1,1,1),
array(3=>1,1,1,1),
array(4=>1,1,1),
array(5=>1,1),
array(6=>1));
// I try to mirror k about diagonal, while doubling:
foreach($k as $i=>& $_k)
foreach($_k as $j=>&$__k)
{
$__k *= 2;
if ($i != $j)
$k[$j][$i ] = $__k;
}
// however:
for ($i=1; $i <= 6; $i++)
{
for ($j=1; $j <= 6; $j++)
echo $k[$i][$j]." ";
echo "<BR>";
}

?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация