PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Your code works fine. Seems a bit silly incrementing $i after you've returned from the function and $i has been destroyed, but the code works exactly how I would expect it to nonetheless. If you want to return "apple is 2" you just need to increment the value of i before it's returned ... eg