Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
406 views
in Server Side Scripting Using PHP by (29.4k points)
closed by

How do we declare an array in php?

1 Answer

+1 vote
by (30.3k points)
selected by
 
Best answer

Arrays in PHP

In PHP array is a collection of key and value pairs. Unlike C++, in PHP we can use either non negative integers or strings as keys.

Different types of arrays in PHP 

  • Indexed arrays 
  • Associate arrays 
  • Multi dimensional arrays.

1. Indexed arrays:

The elements in an array can be distinguished as first or second or third etc. by the indices and the index of the first element is zero. In PHP the function array() is used to create an array.

Syntax:

$array_name=array(value1 ,value2,……….);

OR

2 Associative arrays 

Arräys with named keys and string indices are called associative arrays.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...