Q
What is the purpose of the array_key_exists() function in PHP?

Answer & Solution

Answer: Option A
Solution:
The array_key_exists() function in PHP is used to check if a specified key exists in an array.
Related Questions on Average

Which of the following statements is true about associative arrays in PHP?

A). They only allow numeric indices

B). They store elements in a sequential order

C). They use key-value pairs to access elements

D). They cannot be accessed using loop constructs

What is the correct syntax for creating a multidimensional array in PHP?

A). $array = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));

B). $array = array([1, 2, 3], [4, 5, 6], [7, 8, 9]);

C). $array = array{1, 2, 3}, {4, 5, 6}, {7, 8, 9};

D). $array = array{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

Which PHP function is used to remove the last element from an array?

A). remove()

B). pop()

C). delete()

D). unset()

What will be the output of the following PHP code?
<?php
$numbers = array(10, 20, 30, 40, 50);
array_pop($numbers);
foreach ($numbers as $number) {
echo $number . ' ';
}
?

A). 20 30 40 50

B). 10 20 30 40

C). 10 20 30 40

D). 10 20 30 40 50

What will be the output of the following PHP code?
<?php
$arr = array(10, 20, 30, 40, 50);
$slice = array_slice($arr, 2);
foreach ($slice as $item) {
echo $item . ' ';
}
?

A). 10 20 30 40 50

B). 10 20

C). 30 40 50

D). 30 40 50

Which PHP function is used to merge two or more arrays into a single array?

A). merge()

B). combine()

C). concat()

D). array_merge()

Which PHP construct is commonly used to iterate over elements of an array?

A). foreach loop

B). while loop

C). do-while loop

D). for loop

What is the output of the following PHP code?
<?php
$colors = array('Red', 'Green', 'Blue');
echo $colors[1];
?

A). Red

B). Green

C). Blue

D). 1

What will be the output of the following PHP code?
<?php
$info = array('name' => 'Alice', 'age' => 25);
echo count($info);
?

A). 1

B). 2

C). 25

D). Alice

What will be the output of the following PHP code?
<?php
$info = array('name' => 'John', 'age' => 30, 'city' => 'New York');
echo array_key_exists('age', $info) ? 'Yes' : 'No';
?

A). Yes

B). No

C). John

D). 30