I'm reading source code of this link Source
I have below Javascript code
<script type="text/javascript">
jQuery && jQuery(function() {
setTimeout(function() {
DL.items_list.initItemAttr(4, '{"sku-SV023435_B_M":"e90dfb84e30edf611e326eeb04d680de6c2de33453d563b7965b97195e855512","sku-SV023435_BL_M":"9594eec95be70e7b1710f730fdda33d96c2de33453d563b7965b97195e855512","sku-SV023435_PU_M":"b9ba865fec061c9706d2fd7ce49c0cc76c2de33453d563b7965b97195e855512"}', '{"price":"5.07","products_dropship_price":"0.0000","has_discount_price":false}', "", '{"sku-SV023435_B_M":7,"sku-SV023435_BL_M":10,"sku-SV023435_PU_M":11}', '{"image_e90dfb84e30edf611e326eeb04d680de":"http:\/\/img1.dresslink.com\/SV\/0\/SV023435-8484-SV023435-G.jpg","image_9594eec95be70e7b1710f730fdda33d9":"http:\/\/img1.dresslink.com\/SV\/0\/SV023435-8484-SV023435-G.jpg","image_b9ba865fec061c9706d2fd7ce49c0cc7":"http:\/\/img1.dresslink.com\/SV\/0\/SV023435-8484-SV023435_PU-G.jpg"}');
}, 2000);
var de = $('#w_pro_detail');
de.find('#switchItem').click(function(){
var _t = $(this);
if(_t.is('.narrow')){
var p_wh = _t.parent().width();
_t.attr('class','expend').text('>>').parent().animate({left:0,opacity:1},500).css({opacity:1,paddingRight:20});
_t.parent().find('.p_info,.size_color,.quantity').hide();
de.css('min-width','0');
UtilTool.setCookie('isMiniQuickShop', '1', 24);
}else{
_t.attr('class','narrow').text('<<').parent().animate({left:10},500);
_t.parent().find('.p_info,.size_color,.quantity').show();
de.css('min-width','480px');
UtilTool.setCookie('isMiniQuickShop', '', 0);
}
}).end().mouseover(function(event){
var elem = $(event.currentTarget),
fromElem = $(event.target);
if(elem.has(fromElem).length || fromElem.is(elem)){
de.stop();
de.animate({opacity:1},500);
}
}).mouseout(function(event){
var elem = $(event.currentTarget),
toElem = $(event.target);
if(!elem.has(toElem).length || toElem.is(elem)){
de.stop();
de.animate({opacity:0.15},500);
}
});
var isMiniQuickShop = UtilTool.getCookie('isMiniQuickShop');
if(isMiniQuickShop == '1') {
de.css('min-width','0');
$('#w_pro_detail').find('#switchItem').text('>>').attr('class','expend').end().css({opacity:1,left:0,paddingRight:20}).find('.p_info,.size_color,.quantity').hide();
}
});
</script>
Out of this code below json part is important for me, it has stock availability for each SKU.
'{"sku-SV023435_B_M":7,"sku-SV023435_BL_M":10,"sku-SV023435_PU_M":11}'
Now please help me how I can get this part using PHP and preg_match or any suitable function.
Thanks!
Update: The number os SKUs are not same , it differs from one to unlimited. here is another sample :
'{"sku-11430_B_S":"20","sku-11430_B_M":"17","sku-11430_B_L":"30","sku-11430_B_XS":"13","sku-11430_BL_S":"7","sku-11430_BL_M":"17","sku-11430_BL_L":"4","sku-11430_BL_XS":"16","sku-11430_O_S":"8","sku-11430_O_M":"6","sku-11430_O_L":"22","sku-11430_O_XS":"20","sku-11430_LBL_S":"27","sku-11430_LBL_M":"25","sku-11430_LBL_L":"22","sku-11430_LBL_XS":"10","sku-11430_Y_S":"24","sku-11430_Y_M":36,"sku-11430_Y_L":"20","sku-11430_Y_XS":"6","sku-11430_RR_S":"4","sku-11430_RR_M":"35","sku-11430_RR_L":"47","sku-11430_RR_XS":"6"}',