Skip to content

Instantly share code, notes, and snippets.

View GordonLesti's full-sized avatar

Gordon Lesti GordonLesti

View GitHub Profile
@GordonLesti
GordonLesti / levenshtein1.php
Created February 5, 2014 12:21
Levenshtein distance 1
<?php
function getLevenshtein1($word)
{
$words = array();
for ($i = 0; $i < strlen($word); $i++) {
// insertions
$words[] = substr($word, 0, $i) . '_' . substr($word, $i);
// deletions
$words[] = substr($word, 0, $i) . substr($word, $i + 1);
@GordonLesti
GordonLesti / arrayFillBenchmark.php
Last active August 29, 2015 14:13
PHP Array Fill Benchmark
<?php
$max = 10000000;
$testValues = range(1, $max);
echo php_uname();
echo "\nFill Array with appending elements and for loop\n";
$time = microtime(true);
$newArray = [];
@GordonLesti
GordonLesti / multiarrayaccess.php
Created February 20, 2015 18:23
Multidimensional ArrayAccess
<?php
class MultiArrayAccess implements ArrayAccess
{
public function offsetExists($offset)
{
echo " EXISTS ";
print_r($offset);
echo "\n";
}