Im trying to create a single array with 100 items. First for-loop runs 10 times, and for each run it runs another for-loop who inserts 10 items into the array.
But the result is only the last 10 items:
class Feed {
public $url;
public $title;
}
function feeds_array() {
for ($x = 0; $x <= 10; $x++) {
$feeds = feed($x);
}
return $feeds;
}
function feed($x) {
for ($i = 1; $i <= 10; $i++) {
$feed = new Feed();
$feed->url = "u" . $x;
$feed->title = "t" . $i;
$feeds[] = $feed;
}
return $feeds;
}
$feeds = feeds_array();
foreach ($feeds as $feed) {
echo 'This feed is a ' . $feed->url . ' ' . $feed->title;
echo "<br>";
}