PHP array_replace_recursive() FunctionLast Updated : 17 Mar 2025 The array_replace_recursive() function is an inbuilt function of PHP. The array_replace_recursive( ) function is used to replace the values from passed arrays into the first array recursively. This function was introduced in PHP 5.3.0. SyntaxParameter
Return typeThe array_replace_recursive( ) function returns the replaced array. It will return null if an error occurs. Example 1Output:
Array
(
[a] => Array
(
[0] => all
)
[b] => Array
(
[0] => black
)
)
Example 2Output:
Array
(
[a] => Array
(
[0] => saffron
)
[b] => Array
(
[0] => pink
[1] => red
)
)
Example 3Output:
Array
(
[a] => Array
(
[0] => yuvraj
)
[b] => Array
(
[0] => ishant
[1] => sehwag
)
)
Example 4Output:
Array
(
[a] => Array
(
[0] => Perl
)
[b] => Array
(
[0] => HTML
[1] => PHP
)
)
Next TopicPhp-array-reset-function |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India