Array

PHP Quiz

Questions:9
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Backwards navigation:Allowed

This PHP quiz contains questions for PHP developers to test their knowledge in the PHP language.
This is a free online PHP quiz.
PHP language is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

Start quiz

ArrayObject as a parameter to "is_array" function

True/false question

What is the return value of ‘is_array’ function which gets ArrayObject as parameter?

Return an Array from PHP Function

Multiple choice question

How can a function return an array in PHP?

PHP array of arrays

Multiple choice question

PHP arrays are a useful way to handle series of variables. An array can hold another array.
What will be the output of the following code?

$tops = array(
0=>array("user_id"=>34, "user_name"=>"Dan"),
1=>array("user_id"=>35, "user_name"=>"Ben"),
2=>array("user_id"=>36, "user_name"=>"Roy"));

foreach ($tops as $key=>$top){
$top["user_id"] = $key;
}
echo " {$tops[0]["user_id"]} ";

Swap elements at Macro

Multiple choice question

What will be the output of the following C program?

#include <stdio.h>
#define SWAP (T,A,B) {\
T temp;\
temp = A;\
A = B;\
B= temp;\
}

int main()
{
  int arr[] = { 3,4,5,6,7,8,9);
  int j;
  int i=2;

  SWAP(int, i , arr[i])
  for(j=0;j<7;j++)
   printf(“%d “, arr[j]);
  return 0;
}

What value the 4th element will have

Multiple choice question

What value the 4th element will have?

char arr[10] = {'a','b','c'};

string vs array of chars

True/false question

Does the following two statements the same:
char arr[] = {'a','b'};
char arr[] = "ab";

we can't control the way the array is allocated

True/false question

In ANSI C, we can't control the way the array is allocated and we can't be sure that the array will be allocated in a sequential place.

Syndicate content