Jump to content

[SOLVED] search an array (ignore caps)


thewooleymammoth

Recommended Posts

I cant find any functions that will search an array for a string and ignore the caps

 

example

<?php
$arr=array('random info random', 'blah ha blah', 'blah INFO blah');

$search='info';

for each($arr as $b)
{
if (search_function($search, $b))
  {
   echo "$b <br>";
   }
}
>?

 

the result i need would be...

 

random info random

blah INFO blah

 

if there is no function that can do that, anyone have any ideas of how to do this?

Link to comment
https://forums.phpfreaks.com/topic/127617-solved-search-an-array-ignore-caps/
Share on other sites

<?php
$arr=array('random info random', 'blah ha blah', 'blah INFO blah');
$search='info';

foreach($arr as $str) {
        if (stripos($str, $search) !== false) {
              echo "$str <br />";
        }
}
?>

 

perfect thank you, you dont know how long i was trying to find that for

<?php
$arr=array('random info random', 'blah ha blah', 'blah INFO blah');
$search='info';

foreach($arr as $str) {
        if (stripos($str, $search) !== false) {
              echo "$str <br />";
        }
}
?>

incase you wanted to know i used the code here, www.fatalinjury.org/list.php?dir=pics

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.