Jump to content

find/search in array

- - - - -

  • Please log in to reply
1 reply to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
hi guys

i want search in value array

this is my code


$array = array(0 => 'blue', 1 => 'red', 2 => 'green d3', 3 => 'red rd');


echo array_search('green', $array);

but this code is unique, i need find value

for example my code must be show: 2

help me pelase

thank you

#2
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts
You could try looping through the array, and using the strpos() function on the value at each index to see if your string is contained as a substring.

EDIT: Here is the PHP manual for strpos()
My Company - My Homepage - My Twitter - My Google+ - My LinkedIn

"Things don’t have to change the world to be important.” - Steve Jobs




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users