Jump to content
php.lv forumi

ID iegūšana no masīva string elementa


senters

Recommended Posts

Kā (un kāds būtu labākais veids) no masīva string elementa izkasīt ārā itemid ciparu?

Array (
[currency] => LVL
[shipping] => 0
[tax] => 0
[taxRate] => 0
[itemCount] => 3
[item_name_1] => Preces nosaukums x
[item_quantity_1] => 1
[item_price_1] => 10
[item_options_1] => itemno: 14, itemid: 53, image: img/catalog/xxx/ico/14.jpg, key: 000014
[item_name_2] => Preces nosaukums y
[item_quantity_2] => 1
[item_price_2] => 10
[item_options_2] => itemno: 15, itemid: 54, image: img/catalog/xxx/ico/15.jpg, key: 000015
[item_name_3] => Preces nosaukums z
[item_quantity_3] => 1
[item_price_3] => 5
[item_options_3] => itemno: 2, itemid: 91, image: img/catalog/xxx/ico/2.jpg, key: A00002
)
Edited by senters
Link to comment
Share on other sites


$string = "itemno: 15, itemid: 541, image: img/catalog/xxx/ico/15.jpg, key: 000015";

 

preg_match_all("/itemid: ([0-9]+),/",$string,$matches);

print_r($matches[2]);

 

 

 

Edited by waplet
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...