What are some tips for optimizing PHP code when working with arrays and graphs?

When working with arrays and graphs in PHP, one tip for optimizing code is to use built-in array functions such as array_map, array_filter, and array_reduce instead of loops for better performance. Example:

// Using array_map to apply a function to each element of an array
$array = [1, 2, 3, 4, 5];
$multipliedArray = array_map(function($num) {
    return $num * 2;
}, $array);
print_r($multipliedArray);