Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 452 Bytes

ArrayPushShorthand.md

File metadata and controls

21 lines (14 loc) · 452 Bytes

ArrayPushShorthand

If you use array_push() to add one element to an array it's better to use $array[] = because in that way there is no overhead of calling the function.

Before

<?php
array_push($array, 1); // ArrayPushShorthand: Since `array_push()` has the function call overhead, Consider using `$array[] =`.

After

<?php
$array[] = 1; // OK!

Reference

https://secure.php.net/manual/function.array-push.php