File: src/Bitap/pattern_alphabet.php

Recommend this page to a friend!
  Classes of AccountKiller  >  Fuse  >  src/Bitap/pattern_alphabet.php  >  Download  
File: src/Bitap/pattern_alphabet.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Fuse
Fuzzy search of arrays using the Bitap algorithm
Author: By
Last change:
Date: 3 years ago
Size: 336 bytes
 

Contents

Class file image Download
<?php namespace Fuse\Bitap;

function
pattern_alphabet($pattern)
{
   
$mask = [];
   
$len = mb_strlen($pattern);

    for (
$i = 0; $i < $len; $i++) {
       
$mask[mb_substr($pattern, $i, 1)] = 0;
    }

    for (
$i = 0; $i < $len; $i++) {
       
$mask[mb_substr($pattern, $i, 1)] |= 1 << ($len - $i - 1);
    }

    return
$mask;
}


For more information send a message to info at phpclasses dot org.