Jump to content

[SOLVED] Searching within an array element


eludlow

Recommended Posts

I have an array in which each element is two numbers separated by a comma, eg 50,3

 

How would I go about checking whether a certain number matches the first half of the element?  Ie, I provide a variable $x and want to output each element that starts $x,5 or $x,49 etc etc

 

I tried using in_array but then realised that this only matched the element in its entirety.  I've a feeling it may need regular expressions?

 

Many thanks,

Ed Ludlow

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.