...

/

New Array Handling Techniques

New Array Handling Techniques

Learn about the new array handling methods that help developers perform multiple array operations with very few lines of code.

There have been a number of improvements in PHP 8 array- and string-handling techniques. Although there is insufficient space in this course to cover every single enhancement, we will examine the more significant improvements in this lesson.

Working with the array_splice() method

The array_splice() function is a cross between substr() and str_replace(): it lets us replace a subset of one array with another. Its use gets awkward, however, when all we need to do is replace the last part of the array with something different. A quick look at the syntax reveals where it starts to get inconvenient—the ...