thewooleymammoth Posted October 8, 2008 Share Posted October 8, 2008 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 More sharing options...
DarkWater Posted October 8, 2008 Share Posted October 8, 2008 <?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 />"; } } ?> Link to comment https://forums.phpfreaks.com/topic/127617-solved-search-an-array-ignore-caps/#findComment-660324 Share on other sites More sharing options...
thewooleymammoth Posted October 8, 2008 Author Share Posted October 8, 2008 <?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 Link to comment https://forums.phpfreaks.com/topic/127617-solved-search-an-array-ignore-caps/#findComment-660334 Share on other sites More sharing options...
DarkWater Posted October 8, 2008 Share Posted October 8, 2008 No problem. Be sure to keep that '!== false' construct in there, it's important with strpos() and stripos(). Link to comment https://forums.phpfreaks.com/topic/127617-solved-search-an-array-ignore-caps/#findComment-660335 Share on other sites More sharing options...
thewooleymammoth Posted October 8, 2008 Author Share Posted October 8, 2008 <?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 Link to comment https://forums.phpfreaks.com/topic/127617-solved-search-an-array-ignore-caps/#findComment-660352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.