DEV Community

Programming Dive
Programming Dive

Posted on • Edited on

1 1

Generators in PHP

PHP 5.5 came up with an interesting function to the PHP ecosystem and that was Generators. So while using generators in PHP, we’ll see what are generators and what are different ways of using it.

The structure of generators are similar to the normal functions itself. But in generators instead of return statement, we use yield. Weird, right?. Basically this how generators need to be defined.

So, generators basically loops through an data and avoids large amount of memory for that Array. Yes, generators works with an Array and while creating new array out of the loops it avoids utilizing large amount of memory.

https://programmingdive.com/using-generators-in-php/

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more