Re: Die Frage des Tages
Verfasst: 3. Sep 2013 14:08
Wer "Fußball verstehen" und "Informatik verstehen" so relationiert, hält wahrscheinlich Theologie für eine Wissenschaft.
Wer ist denn der Wettgegner?
Wer ist denn der Wettgegner?
Kunststück; das trifft praktisch auf jeden von uns zu...mordsfilm hat geschrieben: Ich hatte vorausgesagt, dass derjenige im Forum, der soviel von Fußball versteht wie ich von Informatik, sich als Erster zu Wort meldet.
Octavia Combi RS TDI DSG, hab ich grad auf AutoScout eingestellt.mordsfilm hat geschrieben:FdT
Was fahre ich nächstes Jahr?
Code: Alles auswählen
<?php
$a = array(1,2,3);
$b = array(2,4,6);
$c = $a + $b;
print_r($c);
?>Code: Alles auswählen
Array
(
[0] => 1
[1] => 2
[2] => 3
)Code: Alles auswählen
<?php
$a = array(1,2,3);
$b = array(2,4,6);
$c = array();
for ($i=0;$i<count($a);$i++)
{
$c[$i] = $a[$i] + $b[$i];
}
print_r($c);
?>
Array
(
[0] => 3
[1] => 6
[2] => 9
)
Der + Operator ist also nicht anhängen, sondern eine Art "Vereinigungsmenge", bei der aber die Keys der linken Seite komplett übernommen werden.http://us.php.net/manual/en/language.operators.array.php hat geschrieben:The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.
Code: Alles auswählen
function addieren($x, $y){
return $x + $y;
}
$a = array(1,2,3);
$b = array(2,4,6);
$c = array_map('addieren', $a, $b);
var_dump($c);