Skip to content

Instantly share code, notes, and snippets.

@gemblue gemblue/basic.php
Last active Sep 11, 2016

Embed
What would you like to do?
PHP Generator Function
<?php
// Get number
function get_one_two_three() {
for ($i = 1; $i <= 3; $i++) {
yield $i;
}
}
$result = get_one_two_three();
foreach ($result as $value) {
echo "$value\n";
}
// Helper
function convert($size)
{
$unit=array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo 'Memory terpakai : ' . convert(memory_get_usage(true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.