Skip to content

Instantly share code, notes, and snippets.

@DASPRiD
Created March 30, 2015 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DASPRiD/937475489456c7c90dfd to your computer and use it in GitHub Desktop.
Save DASPRiD/937475489456c7c90dfd to your computer and use it in GitHub Desktop.
PHP vectors
<?php
$intVector = Vector<int>(53, 32, 43);
$stringVector = Vector<string>('foo', 'bar', 'baz');
$arrayVector = Vector<array>(array('a'), array('b'));
$vectorVector = Vector<Vector<int>>(Vector<int>(1, 2), Vector<int>(2, 3));
$classVector = Vector<\stdClass>(new \stdClass(), new \stdClass());
foreach ($intVector as $key => $value) {
// Do something.
}
function foo(Vector<int> $values)
{
// May support lazy conversion of arrays into vector
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment