Skip to content

Instantly share code, notes, and snippets.

@flavius
Created April 22, 2011 07:30
Show Gist options
  • Save flavius/936212 to your computer and use it in GitHub Desktop.
Save flavius/936212 to your computer and use it in GitHub Desktop.
<?php
function push_stack($stack, $idx, $val) {
$val = array($idx => $val);//val is a zval*, the data its points to is already allocated on the heap, no duplication is needed
$stack[] = $val;
return $stack;
}
$stack = array();
$val = array('foo');
$stack = push_stack($stack, 7, $val);
var_dump($stack);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment