Problem with function in array (PHP)

Hello Friends

I Have a Problem in my Function. I have created a Recursion Function in PHP and also Created an Array.
I am having trouble in storing this Recursion Function Value in Array.
Can anyone help me with this.

Thanks

could you post the function you have created so far? Without it it’s quite impossible to answer your question as we cannot see where you went wrong :slight_smile:

$myArray = array()

for ($i=0;$i<100;$i++) {
$myArray = i;
}

  1. This is not a function
  2. Since it’s not a function, it cannot be recursive (at most we can say what you made is iterative)
  3. There is an error, it should be $myArray = $i; (forgot the $)

yeah, I know all that.
I was not the one asking the question ScallioXTX…

I know. But what question were you answering??

confused

haha, I was giving an example of a loop filling an array :stuck_out_tongue:


<?php
class Rocket
{
   private $location;
   private $onArrivalCallbacks;

   function construct()
   {
      $this->onArrivalCallbacks = array();
	 }

   public function flyTo($location)
   {
      $this->location = $location;
      $this->handleOnArrival();
   }
   public function onArrival($callback)
   {
      $this->onArrivalCallbacks[] = $callback;
   }
   public function handleOnArrival()
   {
     foreach($this->onArrivalCallbacks as $callback)
     {
        call_user_func($callback);
     }
   }
	 public function getLocation()
	 {
		 return $this->location;
	 }
}

class Person
{
   private $name;
	 private $rocket;
   public function setName($name)
   {
      $this->name = $name;
   }
   public function saySomethingHistorical()
   {
      echo $this->name, ' @ ', $this->rocket->getLocation()->getName(), ": That's one small step for man, one giant leap for mankind.";
   }
	 public function addToRocket($rocket)
	 {
		 $this->rocket = $rocket;
	 }
}

class Location
{
   private $name;
   public function setName($name)
   {
      $this->name = $name;
   }
	 public function getName()
	 {
		 return $this->name;
	 }
}

$p = new Person;
$p->setName('Neil Armstrong');
$l = new Location;
$l->setName('The Moon');
$r = new Rocket;
$p->addToRocket($r);
$r->onArrival(array($p, 'saySomethingHistorical'));
$r->flyTo($l);

That’s an example of a simulation of Neil Armstrong going to the moon.
I still don’t get your point :slight_smile:

I like pie.

There you go :cool:

PHP Thread FAIL!

There is no cake.

Apparently not. (:

Sure there is:

The cake is a lie.

Been watching the Matrix lately?
(There is no spoon)

It was a quote from a game called Portal (from the Half Life team) where you are encouraged on by the promise of cake (there will be cake).
It’s a corollary of the goals that we set for ourselves, and of the presence of heaven.
Neither exist (the cake is a lie) but they provide a motivation of sorts.
The realisation of this (there is no cake) is an awakening, that brings you closer to enlightenment.

Such are the foundations on which The Matrix was built, and it is a through a lack of understanding psychological and philosophy idioms that leads to a lack of enjoyment for most people in the later films.

This though however is diverging ever-so-slightly off-topic.

I couldn’t help but noticing “virtualmisc” has disappeared…

Yes, it’s a shame that we couldn’t help him any further.