Update custom_function.php

code optimizing, replacing a for loop by array_walk.