Nie wiem, czy to czego szukam jest aż tak malo popularne, że tego nigdzie nie ma, czy po prostu ja nie umiem szukać...
Mam wielowymiarową tablice ze stringami w kluczach. Chciałbym w niej zostawić tablice w których kluczu znajdzie się dany ciąg znaków. Dokładnie chodzi mi o coś takiego jak array_filter tutaj:
Cytat
Description:
Return array of matching values from array using regular expression.
<?php
class array_ereg {
function array_ereg($pattern) { $this->pattern = $pattern; }
function ereg($string) {
return ereg($this->pattern, $string);
}
}
?>
Usage :
<?php
$matches = array_filter($subject, array(new array_ereg($pattern), 'ereg'));
?>
Example:
<?php
$subject = array ("Thumbs.db", "image001.png", "image001.jpg", "image002.png");
print_r(array_filter($subject, array(new array_ereg("image[0-9]{3}\.png"), 'ereg')));
?>
Outputs:
Array ( [1] => image001.png [3] => image002.png )
Return array of matching values from array using regular expression.
<?php
class array_ereg {
function array_ereg($pattern) { $this->pattern = $pattern; }
function ereg($string) {
return ereg($this->pattern, $string);
}
}
?>
Usage :
<?php
$matches = array_filter($subject, array(new array_ereg($pattern), 'ereg'));
?>
Example:
<?php
$subject = array ("Thumbs.db", "image001.png", "image001.jpg", "image002.png");
print_r(array_filter($subject, array(new array_ereg("image[0-9]{3}\.png"), 'ereg')));
?>
Outputs:
Array ( [1] => image001.png [3] => image002.png )
Tylko, żeby nie brało pod uwagę zawartości tylko klucz.