I am using an XML parser to get product info from a supplier site, I then break it into an array. What I need to be able to do here is to search for a specific model number code and it's accompanying data into a new single array. How do I go about achieving this goal?
For example, if I only needed to collect data for 'CP-iSi7Q2600' from the excerpt below, please keep in mind I need to search for a specfic 'productcode'.
Array
(
[0] => Array
(
[productcode] => CP-ISI7Q2600
[description] => Intel Sb i7 Quad 2600 3.4
[price] => 2299
[stock] => 5
[eta] =>
)
[1] => Array
(
[productcode] => CP-ISI7Q2600K
[description] => Intel Sb i7 Quad 2600K no fan
[price] => 2299
[stock] => -12
[eta] =>
)
[2] => Array
(
[productcode] => CP-ISI7Q2600K
[description] => Intel Sb i7 Quad 2600K no fan
[price] => 2299
[stock] => -12
[eta] => 2011/01/31
)
[3] => Array
(
[productcode] => CP-ISI7Q2600K
[description] => Intel Sb i7 Quad 2600K no fan
[price] => 2299
[stock] => -12
[eta] => 2011/01/19
)
)
I attempted something but it needs refinement:
$product = 'CP-iSi7Q2600';
foreach($product_info_array as $somearray)
{
foreach($somearray as $key => $value)
{
if ($value == strtoupper($product)) { echo 'product found:' . $value; }
}
}
Furthermore, if I am possible to do this, how would I go about lifting out the latest entry for a specific model number? Based on the above example I need to find 'CP-iSi7Q2600K' but the last array only.
I hope you can help, I have limited PHP knowledge as you can see.