Jump to content

Searching for a given value in an Array.


theITvideos

Recommended Posts

Hi there,

 

I'm working on PHP webform and I have a variable called $weightInfo which has the value 5000|6000

 

Now I have a list of Arrays and I would like to see if our variable value (i.e 5000|6000) is in that list of Array: Here is the ArrayList:

 

 

 $WeightArray = array('' => '',    '0|100' => '100g or Less',    '101|250' => '101g to 250g',     '251|500' => '251g to 500g',    '501|1000' => '501g to 1kg',    '1000|2000' => '1kg to 2kg',    '2000|3000' => '2kg to 3kg',    '3000|4000' => '3kg to 4kg',    '4000|5000' => '4kg to 5kg',    '5000|6000' => '5kg to 6kg',    '6000|7000' => '6kg to 7kg',    '7000|8000' => '7kg to 8kg',     '8000|9000' => '8kg to 9kg',      '9000|10000' => '9kg to 10kg',    'customValues' => 'Custom Values'    );

 

 

Now as we can see, in this ArrayList, there is that value 5000|6000.

 

How do we find this through code, do we need some kind of looping or how do we check it.

 

Kindly reply.

 

Thank you :)

Link to comment
https://forums.phpfreaks.com/topic/215466-searching-for-a-given-value-in-an-array/
Share on other sites

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.