Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript数组和php数组_Javascript_Php_Arrays - Fatal编程技术网

javascript数组和php数组

javascript数组和php数组,javascript,php,arrays,Javascript,Php,Arrays,我想把所有的值都输入php,并用它的值打印每个值 Javascript数组 var search_results =[{"products_sold":"94","cyl_lim_up":4,"sph_lim_up":8,"search_face_shapes": ["Oblong"],"pdp_url_base":"eyeglasses","prod_id":"3809","default_psku_id":"7921","brand_name":"Ray- Ban","scene

我想把所有的值都输入php,并用它的值打印每个值

Javascript数组

var search_results =[{"products_sold":"94","cyl_lim_up":4,"sph_lim_up":8,"search_face_shapes":    ["Oblong"],"pdp_url_base":"eyeglasses","prod_id":"3809","default_psku_id":"7921","brand_name":"Ray-    Ban","scene7_company_code":"luxottica","scene7_url_suffix":"","search_sizes":["Medium"],"base_type_friendly":["Glasses"],"sph_lim_dn":-    10,"type_name":"Full-Rim Plastic","max_price":179,"prescription_type":"Progressive\/Multifocal","product_name":"Ray-Ban RX5228","search_genders":    ["Unisex","Women"],"min_price":179,"url_key":"Ray-Ban-RX5228","pd_lim_dn":-100,"base_product_url":["\/glasses\/Ray-Ban-    RX5228"],"pd_lim_up":100,"cyl_lim_dn":-4,"scene7_model_code":"rx5228","scene7_brand_code":"rayban","is_completely_out_of_stock":"0","search_shapes":    ["Square"],"featured_sort_rank":9999,"simple_sort_rank":9999,"active_psku_id":"7921","insurance":null,"show_specialty_lens":true,"skus":    [{"price":"179.00","regular_price":"179.00","scene7_swatch_code":"black","psku_id":"7920","sku_index":0,"supports_rx":"0","polarized":"0","image_code":"luxot    tica_rayban_rx5228_black","upc":"805289445913","color_description":"Shiny Black","specialty_lens_option":"NULL","web_vto_available":"1","frame_weight":30,"lens_width":50,"lens_height":35,"bridge_size":17,"temple_size":140,"vto_path":"Ray-Ban~RX5228-092764cb6bae0671\/805289445913"},{"price":"179.00","regular_price":"179.00","scene7_swatch_code":"tortoise","psku_id":"7921","sku_index":1,"supports_rx":"0","polarized":"0","image_code":"luxottica_rayban_rx5228_tortoise","upc":"805289445890","color_description":"Dark Havana","specialty_lens_option":"NULL","web_vto_available":"1","frame_weight":30,"lens_width":50,"lens_height":35,"bridge_size":17,"temple_size":140,"vto_path":"Ray-Ban~RX5228-092764cb6bae0671\/805289445890"},{"price":"179.00","regular_price":"179.00","scene7_swatch_code":"blue","psku_id":"8220","sku_index":2,"supports_rx":"0","polarized":"0","image_code":"luxottica_rayban_rx5228_blue","upc":"713132453728","color_description":"Blue","specialty_lens_option":"NULL","web_vto_available":"1","frame_weight":30,"lens_width":50,"lens_height":35,"bridge_size":17,"temple_size":140,"vto_path":"Ray-Ban~RX5228-092764cb6bae0671\/713132453728"},{"price":"179.00","regular_price":"179.00","scene7_swatch_code":"red","psku_id":"9185","sku_index":3,"supports_rx":"0","polarized":"0","image_code":"luxottica_rayban_rx5228_red","upc":"713132453780","color_description":"Dark Red Transparent","specialty_lens_option":"NULL","web_vto_available":"1","frame_weight":30,"lens_width":50,"lens_height":35,"bridge_size":17,"temple_size":140,"vto_path":"Ray-Ban~RX5228\/713132453780"},{"price":"179.00","regular_price":"179.00","scene7_swatch_code":"black2","psku_id":"9969","sku_index":4,"supports_rx":"0","polarized":"0","image_code":"luxottica_rayban_rx5228_black2","upc":"805289445876","color_description":"Black on Texture","specialty_lens_option":"NULL","web_vto_available":"0","frame_weight":30,"lens_width":50,"lens_height":35,"bridge_size":17,"temple_size":140,"vto_path":null}],"skuCount":12},{"products_sold":"87","cyl_lim_up":4,"sph_lim_up":8,"search_face_shapes":["Round","Oval"],"pdp_url_base":"eyeglasses","prod_id":"4877","default_psku_id":"10822","brand_name":"Oakley","scene7_company_code":"oakley","scene7_url_suffix":"","search_sizes":["Large"],"base_type_friendly":["Glasses"],"sph_lim_dn":-10,"type_name":"Full-Rim Plastic","max_price":160,"prescription_type":"Progressive\/Multifocal","product_name":"Oakley Tailspin Large","search_genders":["Men"],"min_price":112,"url_key":"Oakley-Tailspin-Large","pd_lim_dn":-100,"base_product_url":["\/glasses\/Oakley-Tailspin-Large"],"pd_lim_up":100,"cyl_lim_dn":-4,"scene7_model_code":"tailspinlarge","scene7_brand_code":"oakley","is_completely_out_of_stock":"0","search_shapes":["Rectangle"],"featured_sort_rank":9999,"simple_sort_rank":9999,"active_psku_id":"10822","insurance":null,"show_specialty_lens":true,"skus":[{"price":"112.00","regular_price":"160.00","scene7_swatch_code":"grey","psku_id":"10822","sku_index":0,"supports_rx":"0","polarized":"0","image_code":"oakley_oakley_tailspinlarge_grey","message":"30% Off","upc":"700285642840","color_description":"Satin Smoke","specialty_lens_option":"NULL","web_vto_available":"0","frame_weight":20,"lens_width":55,"lens_height":33,"bridge_size":18,"temple_size":140,"vto_path":null},{"price":"160.00","regular_price":"160.00","scene7_swatch_code":"gunmetal","psku_id":"10872","sku_index":1,"supports_rx":"0","polarized":"0","image_code":"oakley_oakley_tailspinlarge_gunmetal","upc":"700285831138","color_description":"Black Fade","specialty_lens_option":"NULL","web_vto_available":"0","frame_weight":25,"lens_width":55,"lens_height":33,"bridge_size":18,"temple_size":140,"vto_path":null},{"price":"160.00","regular_price":"160.00","scene7_swatch_code":"black3","psku_id":"10873","sku_index":2,"supports_rx":"0","polarized":"0","image_code":"oakley_oakley_tailspinlarge_black3","upc":"700285830988","color_description":"Satin Black & Orange","specialty_lens_option":"NULL","web_vto_available":"0","frame_weight":20,"lens_width":55,"lens_height":33,"bridge_size":18,"temple_size":140,"vto_path":null}],"skuCount":3}
我使用此脚本获取数组值,但没有成功 php代码:

 $html = file_get_html('http://localhost/scrapping/web.html');

$ctr=0;

$span_cat = $html->find("<script type='text/javascript'>");

//preg_match_all("/\[(\{(.*)\})\]/", $span_cat[0], $matches, PREG_SET_ORDER);
preg_match_all("/\[(\{(.*)\})\]/", $span_cat[0], $matches, PREG_SET_ORDER);

foreach ($matches as $val) {
echo "matched: " . $val[0] . "\n";
}   
$html=file\u get\u html('http://localhost/scrapping/web.html');
$ctr=0;
$span_cat=$html->find(“”);
//preg\u match\u all(“/\[(\{(.*})\]/”,$span\u cat[0],$matches,preg\u SET\u顺序);
preg\u match\u all(“/\[(\{(.*})\]/”,$span\u cat[0],$matches,preg\u SET\u顺序);
foreach($匹配为$val){
回显“匹配:.”val[0]。“\n”;
}   

请帮我解决这个问题,我会非常感谢你的工作。你能给我解释一下我们如何使用json吗?基本上有很多括号和逗号。请帮忙