Skip to main content

🛍️ BLACK FRIDAY get-one-give-one sale is underway. Don't miss $50 off PLUS a free subscription to gift a friend. 🤩

🚀 In our NEW AI Bootcamp you'll build a working app in 28 days, no experience required. Free to all subscription levels.

Join the Treehouse affiliate program and earn 25% recurring commission! 🤑

  • Treehouse Logo
    • For Individuals
    • For Businesses
    • For Schools
    • For Libraries
    • For Military
    • All Courses
    • Tracks
    • AI Bootcamp
    • College Credit
    • Techdegree Bootcamps
    • Front End Development
    • Full Stack JavaScript
    • Code Adventures
    • Discord
    • Forum
    • Success Stories
    • Treehouse Links
    • 100 Days of Code
    • Explore
    • Career Toolbox
    • Free Treehouse Near Me
    • Affiliates
    • Blog
    • Support
    • About
    • Learn
    • Beginner's Guide to Coding
    • Data Analysis with SQL & Python
    • Front-End Web Development
    • Python Programming Basics
    • Techdegree Bootcamp Overview
    • UX Design Fundamentals
    • AI Tools for Beginners
  • For Individuals For Businesses For Schools For Libraries For Military
  • All Courses Tracks AI Bootcamp College Credit
  • Techdegree Bootcamps Front End Web Development Full Stack JavaScript
  • Code Adventures Discord Forum Success Stories Treehouse Links 100 Days of Code
  • Explore Career Toolbox Free Treehouse Near Me Affiliates Blog Support About
    Learn Beginner's Guide to Coding Data Analysis with SQL & Python Front-End Web Development Python Programming Basics Techdegree Bootcamp Overview UX Design Fundamentals AI Tools for Beginners
  • Sign In
  • Free Trial
Instagram Twitter Facebook YouTube LinkedIn
Loading banner... Start your free trial at Treehouse
    • Newest
      • Newest
      • Active
      • Unanswered
      • Featured
    • All Topics
      • All Topics
      • • General Discussion
      • • AI
      • • APIs
      • • Coding for Kids
      • • College Credit
      • • Computer Science
      • • CSS
      • • Data Analysis
      • • Databases
      • • Design
      • • Development Tools
      • • Digital Literacy
      • • Game Development
      • • Go Language
      • • HTML
      • • Java
      • • JavaScript
      • • Learning Resources
      • • Machine Learning
      • • No-Code
      • • PHP
      • • Professional Growth
      • • Python
      • • Quality Assurance
      • • React
      • • Ruby
      • • Security
      • • Swift
      • • Vibe Coding
  • Ryan Schmelter
    Ryan Schmelter
    9,710 Points

    Loop returns one fewer items than the number parameter in array_rand

    Posted June 6, 2019 4:11pm by Ryan Schmelter
    Ryan Schmelter
    9,710 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    1 Answer

  • Daniel Fitzhugh
    Daniel Fitzhugh
    9,715 Points

    Why does array_rand() return a "meta-array" of keys, and not just the original array with a reduced number of items ?

    Posted February 17, 2019 1:05pm by Daniel Fitzhugh
    Daniel Fitzhugh
    9,715 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    1 Answer

  • jlampstack
    jlampstack
    23,932 Points

    How would we write this loop NOT using a function?

    Posted May 11, 2018 3:47pm by jlampstack
    jlampstack
    23,932 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    1 Answer

  • john paul
    john paul
    3,191 Points

    Clarification needed please

    Posted April 4, 2018 9:38pm by john paul
    john paul
    3,191 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    2 Answers

  • Teacher Russell
    Teacher Russell
    16,873 Points

    random fun with arrays

    Posted March 9, 2018 4:46pm by Teacher Russell
    Teacher Russell
    16,873 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    1 Answer

  • jlampstack
    jlampstack
    23,932 Points

    Why do we need 2 parameters in.... function get_item_html($id, $item){}

    Posted March 10, 2017 4:36pm by jlampstack
    jlampstack
    23,932 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    3 Answers

  • Kristian Woods
    Kristian Woods
    23,414 Points

    Why would you want to change the name of the parameter?

    Posted December 21, 2016 11:46am by Kristian Woods
    Kristian Woods
    23,414 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    1 Answer

  • caroline
    caroline
    6,974 Points

    Need help with quiz question

    Posted August 25, 2016 10:00am by caroline
    caroline
    6,974 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    4 Answers

  • filipepacheco
    seal-mask
    .a{fill-rule:evenodd;}techdegree
    filipepacheco
    Full Stack JavaScript Techdegree Student 21,416 Points

    Random Fun with Arrays

    Posted May 3, 2016 11:36pm by filipepacheco
    .a{fill-rule:evenodd;}techdegree
    filipepacheco
    Full Stack JavaScript Techdegree Student 21,416 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    3 Answers

  • thimoschroeder
    thimoschroeder
    23,470 Points

    Why is $id used in the echo statement twice?

    Posted April 21, 2016 11:50am by thimoschroeder
    thimoschroeder
    23,470 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    4 Answers

  • Nathaniel Kolenberg
    Nathaniel Kolenberg
    12,836 Points

    Why use $id as argument in function when not used inside function?

    Posted April 7, 2016 8:11pm by Nathaniel Kolenberg
    Nathaniel Kolenberg
    12,836 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    4 Answers

  • Amber Hoddinott
    Amber Hoddinott
    6,494 Points

    I need some help understanding that last part fo this code please.

    Posted February 25, 2016 1:20pm by Amber Hoddinott
    Amber Hoddinott
    6,494 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    2 Answers

  • michaelleonard4
    michaelleonard4
    7,013 Points

    I don't understand something!

    Posted January 20, 2016 11:37am by michaelleonard4
    michaelleonard4
    7,013 Points
    • PHP
    • Build a Basic PHP Website (2018)
    • Listing and Sorting Inventory Items
    • Random Fun with Arrays

    7 Answers

Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.

Techdegree

  • Front End Web Development
  • Full Stack JavaScript
SEE ALL

Tracks

  • Learn to Code for Beginners
  • Beginning Python
  • Beginning SQL
  • Beginning Java
SEE ALL

Courses

  • JavaScript Basics
  • Intro to HTML & CSS
  • Python Basics
  • CSS Layout
SEE ALL

About Us

  • About
  • Blog
  • Community
  • Stories
  • Contact
  • Gift Card

Explore

  • Plans
  • Affiliates
  • Perks
  • Shop
  • Free Treehouse Near Me
  • Treehouse for Libraries
  • Treehouse for Businesses

Treehouse is an online technology education platform founded in 2011. Treehouse offers more than 700 self-paced, video-based courses in web development, programming, data analysis, design, and AI, plus two project-based bootcamp programs in Front End Web Development and Full Stack JavaScript. Individual Treehouse plans start at $25 per month and include a 7-day free trial. Treehouse serves individual learners, businesses, schools, and public libraries. Cardholders at participating U.S. public libraries can use Treehouse for free. Select Treehouse courses, offered with University Pathways International, are recommended for college credit by ACE and NCCRS. Treehouse learners earn digital certificates for completed Tracks.

Terms & Conditions · Privacy · © 2026 Treehouse Island, Inc.
  • Twitter
  • YouTube
  • Facebook
  • LinkedIn
  • Instagram
  • Discord