Array problem, online solution. I'm depressed for one day. I will try to add it later ~! Thank you very much for array 1.
Array ([0] => Array ([59] => Shanghai [17] => Yes [18] => a car [69] => Ford [21] => 18-25 10 thousand [22] => MPV [23] => reliable quality [24] => Unlock the brakes and slide [26] => Don't worry [28] => no best [30] => it doesn't matter [31] => The lighter the better [33] => when you are free, drill [34] => try your best to plug [35] => no road [36] => balanced and random [40] => frequent occurrence of [43] => Long-bright high-light/fog lights [44] => articles placed on airbags [45] => maintain speed [46] => Increase of boards [47] => willing to [48] => lights [49] => know [50] => low noise [51] => fuel-saving tires [52] => male [53] => 5-[54] => before January 1) [1] => Array ([59] => others) [2] => Array ([59] => Shanghai [17] => Yes [18] => a [69] => Buick [21] => 12-18 thousand [22] => hatchback [23] => affordable [24] => casual [26] => occasional [28] => no best [30] => sedated incorrect operation [31] => The lighter the better [33] => The Last Resort was to change the route [34] => at will [35] => Shashi Road [36] => easy and comfortable [40] => never happened [43] => compete for the same lane, freely throwing garbage, changing lanes and turning without lights [44] => without seat belts, driving with slippers, driving, smoking, and drinking, without using children's seats [45] => keep speed, regular maintenance, selection of fuel-saving tires [46] => replacement of exclusive tires, brake set [47] => willing to [48] => replacement of shock absorber, change the exclusive tire [49] => know [50] => The brakes do not slide, the turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed and stability [51] => tire control [52] => male [53] => 3-5 yuan [54] => 1980-1985 ))
Array 2
The preceding array is compared with the following. the keys and values of array 1 are equal to the wjc_bid and wjc_title of array 2, respectively, and the content of array 1 (text part) replace it with the wjc_dhao (number) of array 2 ).
Do everything you can to achieve it, and seek help from experts online. 100,000 thanks ~!
I don't know if there is no solution?
Reply to discussion (solution)
Returns the var_export of the two arrays.
Returns the var_export of the two arrays.
There is a lot of data. cut a part.
Array 1:
Array (0 => array (59 => 'Shanghai', 17 => 'yes', 18 => 'vehicle 1', 69 => 'Ford ', 21 => '18-0.25 million ', 22 => 'MP', 23 => 'quality true', 24 => 'open the brakes and slide slowly ', 26 => 'random indifferent ', 28 => 'No preview', 30 => 'indifferent', 31 => 'lighter, Better ', 33 => 'drill when ID', 34 => 'try your best to gapp', 35 => 'No Road', 36 => 'balanced free ', 40 => 'frequent occurrence ', 43 => 'long bright high light/fog lamps', 44 => 'put items on the airbag ', 45 => 'Keep The speed ', 46 => 'Add sashboard ', 47 => 'willingness', 48 => 'headlight ', 49 => 'knows', 50 => 'noisy ', 51 => 'fuel-saving tire ', 52 => 'male', 53 => '5-70 thousand', 54 => 'Before March 30 ',), 1 => array (59 => 'others',), 2 => array (59 => 'Shanghai', 17 => 'yes ', 18 => 'vehicle per vehicle ', 69 => 'buick', 21 => '12-0.18 million ', 22 => 'hatchback', 23 => 'affordable ', 24 => 'random indifferent ', 26 => 'occasional', 28 => 'No preview', 30 => 'stationary no misoperations ', 31 => 'lighter, better, ', 33 => 'do not have to make a change.', 34 => 'HUMBLE. ', 35 => 'Shashi Road ', 36 => 'easy and comfortable ', 40 => 'never occurred', 43 => 'compete for the same lane, scatter garbage, and turn the road without making any Lamps ', 44 => 'do not fasten your seat belt, drive with slippers, smoke and drink while driving, do not use children's seat ', 45 => 'maintain speed, regular maintenance, choose fuel-saving tires ', 46 => 'change the exclusive tyre, brake bundle ', 47 => 'willing', 48 => 'change the shock absorber, change the exclusive tire ', 49 => 'day ', 50 => 'The brakes do not slide, turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed stability ', 51 => 'tires control', 52 => 'male', 53 => '3-50 thousand RMB ', 54 => '2017-123 ',), 3 => array (59 => 'others ',),..................
Array 2
Array (0 => array ('WC _ id' => '000000', 'WC _ bid' => '59', 'WC _ dhao' => '1 ', 'WC _ title' => 'Shanghai', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 1 => array ('WC _ id' => '56', 'WC _ bid' => '17 ', 'WC _ dhao' => '1', 'WC _ title' => 'Yes', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 2 => array ('WC _ id' => '58 ', 'WC _ bid' => '18', 'WC _ dhao' => '1', 'WC _ title' => 'mapp ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 3 => array ('WC _ id' => '000000', 'WC _ bid' => '69', 'WC _ dhao' => '4 ', 'WC _ title' => 'Ford ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 4 => array ('WC _ id' => '85', 'WC _ bid' => '21 ', 'WC _ dhao' => '4', 'WC _ title' => '18-0.25 million ', 'WC _ tiaojian' => '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 5 => array ('WC _ id' => '92 ', 'WC _ bid' => '22', 'WC _ dhao' => '4', 'WC _ title' => 'MP ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 6 => array ('WC _ id' => '97 ', 'WC _ bid' => '23', 'WC _ dhao' => '4 ', 'WC _ title' => 'quality true', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 7 => array ('WC _ id' => '123', 'WC _ bid' => '24 ', 'WC _ dhao' => '1', 'WC _ title' => 'open the brakes and slide slowly. ', 'WC _ tiaojian' => '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 8 => array ('WC _ id' => '123 ', 'WC _ bid' => '26', 'WC _ dhao' => '4', 'WC _ title' => 'random indifferent ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 9 => array ('WC _ id' => '000000', 'WC _ bid' => '28', 'WC _ dhao' => '1 ', 'WC _ title' => 'no preview', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 10 => array ('WC _ id' => '123', 'WC _ bid' => '30 ', 'WC _ dhao' => '4', 'WC _ title' => 'indifferent', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL ,),...................
What does this mean?
$ A = array (0 => array (59 => 'Shanghai', 17 => 'Yes', 18 => 'vehicle one', 69 => 'Ford ', 21 => '18-0.25 million ', 22 => 'MP', 23 => 'quality true', 24 => 'open the brakes and slide slowly ', 26 => 'random indifferent ', 28 => 'No preview', 30 => 'indifferent', 31 => 'lighter, Better ', 33 => 'drill when ID', 34 => 'try your best to gapp', 35 => 'No Road', 36 => 'balanced free ', 40 => 'frequent occurrence ', 43 => 'long bright high light/fog lamps', 44 => 'put items on the airbag ', 45 => 'Keep The speed ', 46 => 'Add sashboard ', 47 => 'willingness', 48 => 'headlight ', 49 => 'knows', 50 => 'noisy ', 51 => 'fuel-saving tire ', 52 => 'male', 53 => '5-70 thousand', 54 => 'Before March 30 ',), 1 => array (59 => 'others',), 2 => array (59 => 'Shanghai', 17 => 'yes ', 18 => 'vehicle per vehicle ', 69 => 'buick', 21 => '12-0.18 million ', 22 => 'hatchback', 23 => 'affordable ', 24 => 'random indifferent ', 26 => 'occasional', 28 => 'No preview', 30 => 'stationary no misoperations ', 31 => 'lighter, better, ', 33 => 'do not have to make a change.', 34 => 'HUMBLE. ', 35 => 'Shashi Road ', 36 => 'easy and comfortable ', 40 => 'never occurred', 43 => 'compete for the same lane, scatter garbage, and turn the road without making any Lamps ', 44 => 'do not fasten your seat belt, drive with slippers, smoke and drink while driving, do not use children's seat ', 45 => 'maintain speed, regular maintenance, choose fuel-saving tires ', 46 => 'change the exclusive tyre, brake bundle ', 47 => 'willing', 48 => 'change the shock absorber, change the exclusive tire ', 49 => 'day ', 50 => 'The brakes do not slide, turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed stability ', 51 => 'tires control', 52 => 'male', 53 => '3-50 thousand RMB ', 54 => '2017-123 ',), 3 => array (59 => 'others',),); $ B = array (0 => array ('wjc _ id' => '123 ', 'WC _ bid' => '59', 'WC _ dhao' => '1', 'WC _ title' => 'Shanghai ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 1 => array ('WC _ id' => '56 ', 'WC _ bid' => '17', 'WC _ dhao' => '1 ', 'WC _ title' => 'yes', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 2 => array ('WC _ id' => '58', 'WC _ bid' => '18 ', 'WC _ dhao' => '1', 'WC _ title' => 'vehicle 1', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 3 => array ('WC _ id' => '123 ', 'WC _ bid' => '69 ', 'WC _ dhao' => '4', 'WC _ title' => Ford ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 4 => array ('WC _ id' => '85', 'WC _ bid' => '21', 'WC _ dhao' => '4 ', 'WC _ title' => '18-0.25 million ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 5 => array ('WC _ id' => '92', 'WC _ bid' => '22 ', 'WC _ dhao' => '4', 'WC _ title' => 'MP', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 6 => array ('WC _ id' => '97 ', 'WC _ bid' => '23', 'WC _ dhao' => '4', 'WC _ title' => 'quality true ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 7 => array ('WC _ id' => '000000', 'WC _ bid' => '24', 'WC _ dhao' => '1 ', 'WC _ title' => 'open the brakes and slide slowly ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 8 => array ('WC _ id' => '123', 'WC _ bid' => '26 ', 'WC _ dhao' => '4', 'WC _ title' => 'random indifferent ', 'WC _ tiaojian' => '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 9 => array ('WC _ id' => '123 ', 'WC _ bid' => '28', 'WC _ dhao' => '1', 'WC _ title' => 'no preview ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 10 => array ('WC _ id' => '000000', 'WC _ bid' => '30', 'WC _ dhao' => '4 ', 'WC _ title' => 'indifferent ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,),); foreach ($ a as $ key => $ item) {foreach ($ item as $ k => $ v) {foreach ($ B as $ tmp) if ($ k = $ tmp ['wjc _ bid'] & $ v = $ tmp ['wjc _ title']) $ a [$ key] [$ k] = $ tmp ['wjc _ dhao'] ;}} print_r ($ );
Array ([0] => Array ([59] => 1 [17] => 1 [18] => 1 [69] => 4 [21] => 4 [22] => 4 [23] => 4 [24] => 1 [26] => 4 [28] => 1 [30] => 4 [31] => the lighter the better [33] => drill when you are free [34] => try your best to plug [35] => no road [36] => balanced and random [40] => frequent [43] => Long-bright high-light and fog lights [44] => put items on the airbag [45] => maintain speed [46] => add a Shield [47] => willing to [48]] => lights [49] => know [50] => low noise [51] => fuel-saving tires [52] => male [53] => 5-7 [54] => before January 1, 1960) [1] => Array ([59] => others) [2] => Array ([59] => 1 [17] => 1 [18] => 1 [69] => Buick [21] => 12-18 thousand [22] => hatchback [23] => affordable [24] => casual [26] => occasional [28] => 1 [30] => stable cars do not have misoperations [31] => The lighter the better [33] => The Last Resort is to change the path [34] => Humble [35] => Shashi Road [36] => easy and comfortable [40] => never happened [43] => compete for the same lane, freely throwing garbage, changing lanes and turning without lights [44] => without seat belts, driving with slippers, driving, smoking, and drinking, without using children's seats [45] => keep speed, regular maintenance, selection of fuel-saving tires [46] => replacement of exclusive tires, brake set [47] => willing to [48] => replacement of shock absorber, change the exclusive tire [49] => know [50] => The brakes do not slide, the turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed and stability [51] => tire control [52] => male [53] => 3-5 yuan [54] => 1980-1985) [3] => Array ([59] => others ))
Too messy!
Can you create a structure like array 2 on the first floor?
What does this mean?
$ A = array (0 => array (59 => 'Shanghai', 17 => 'Yes', 18 => 'vehicle one', 69 => 'Ford ', 21 => '18-0.25 million ', 22 => 'MP', 23 => 'quality true', 24 => 'open the brakes and slide slowly ', 26 => 'random indifferent ', 28 => 'No preview', 30 => 'indifferent', 31 => 'lighter, Better ', 33 => 'drill when ID', 34 => 'try your best to gapp', 35 => 'No Road', 36 => 'balanced free ', 40 => 'frequent occurrence ', 43 => 'long bright high light/fog lamps', 44 => 'put items on the airbag ', 45 => 'Keep The speed ', 46 => 'Add sashboard ', 47 => 'willingness', 48 => 'headlight ', 49 => 'knows', 50 => 'noisy ', 51 => 'fuel-saving tire ', 52 => 'male', 53 => '5-70 thousand', 54 => 'Before March 30 ',), 1 => array (59 => 'others',), 2 => array (59 => 'Shanghai', 17 => 'yes ', 18 => 'vehicle per vehicle ', 69 => 'buick', 21 => '12-0.18 million ', 22 => 'hatchback', 23 => 'affordable ', 24 => 'random indifferent ', 26 => 'occasional', 28 => 'No preview', 30 => 'stationary no misoperations ', 31 => 'lighter, better, ', 33 => 'do not have to make a change.', 34 => 'HUMBLE. ', 35 => 'Shashi Road ', 36 => 'easy and comfortable ', 40 => 'never occurred', 43 => 'compete for the same lane, scatter garbage, and turn the road without making any Lamps ', 44 => 'do not fasten your seat belt, drive with slippers, smoke and drink while driving, do not use children's seat ', 45 => 'maintain speed, regular maintenance, choose fuel-saving tires ', 46 => 'change the exclusive tyre, brake bundle ', 47 => 'willing', 48 => 'change the shock absorber, change the exclusive tire ', 49 => 'day ', 50 => 'The brakes do not slide, turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed stability ', 51 => 'tires control', 52 => 'male', 53 => '3-50 thousand RMB ', 54 => '2017-123 ',), 3 => array (59 => 'others',),); $ B = array (0 => array ('wjc _ id' => '123 ', 'WC _ bid' => '59', 'WC _ dhao' => '1', 'WC _ title' => 'Shanghai ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 1 => array ('WC _ id' => '56 ', 'WC _ bid' => '17', 'WC _ dhao' => '1 ', 'WC _ title' => 'yes', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 2 => array ('WC _ id' => '58', 'WC _ bid' => '18 ', 'WC _ dhao' => '1', 'WC _ title' => 'vehicle 1', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 3 => array ('WC _ id' => '123 ', 'WC _ bid' => '69 ', 'WC _ dhao' => '4', 'WC _ title' => Ford ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 4 => array ('WC _ id' => '85', 'WC _ bid' => '21', 'WC _ dhao' => '4 ', 'WC _ title' => '18-0.25 million ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 5 => array ('WC _ id' => '92', 'WC _ bid' => '22 ', 'WC _ dhao' => '4', 'WC _ title' => 'MP', 'WC _ tiaojian '=> '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 6 => array ('WC _ id' => '97 ', 'WC _ bid' => '23', 'WC _ dhao' => '4', 'WC _ title' => 'quality true ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 7 => array ('WC _ id' => '000000', 'WC _ bid' => '24', 'WC _ dhao' => '1 ', 'WC _ title' => 'open the brakes and slide slowly ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,), 8 => array ('WC _ id' => '123', 'WC _ bid' => '26 ', 'WC _ dhao' => '4', 'WC _ title' => 'random indifferent ', 'WC _ tiaojian' => '0 ', 'WC _ jieg' => '0', 'WC _ img '=> NULL,), 9 => array ('WC _ id' => '123 ', 'WC _ bid' => '28', 'WC _ dhao' => '1', 'WC _ title' => 'no preview ', 'WC _ tiaojian '=> '0', 'WC _ jieg' => '0', 'WC _ img '=> NULL ,), 10 => array ('WC _ id' => '000000', 'WC _ bid' => '30', 'WC _ dhao' => '4 ', 'WC _ title' => 'indifferent ', 'WC _ tiaojian' => '0', 'WC _ jieg' => '0 ', 'WC _ img '=> NULL,),); foreach ($ a as $ key => $ item) {foreach ($ item as $ k => $ v) {foreach ($ B as $ tmp) if ($ k = $ tmp ['wjc _ bid'] & $ v = $ tmp ['wjc _ title']) $ a [$ key] [$ k] = $ tmp ['wjc _ dhao'] ;}} print_r ($ );
Array ([0] => Array ([59] => 1 [17] => 1 [18] => 1 [69] => 4 [21] => 4 [22] => 4 [23] => 4 [24] => 1 [26] => 4 [28] => 1 [30] => 4 [31] => the lighter the better [33] => drill when you are free [34] => try your best to plug [35] => no road [36] => balanced and random [40] => frequent [43] => Long-bright high-light and fog lights [44] => put items on the airbag [45] => maintain speed [46] => add a Shield [47] => willing to [48]] => lights [49] => know [50] => low noise [51] => fuel-saving tires [52] => male [53] => 5-7 [54] => before January 1, 1960) [1] => Array ([59] => others) [2] => Array ([59] => 1 [17] => 1 [18] => 1 [69] => Buick [21] => 12-18 thousand [22] => hatchback [23] => affordable [24] => casual [26] => occasional [28] => 1 [30] => stable cars do not have misoperations [31] => The lighter the better [33] => The Last Resort is to change the path [34] => Humble [35] => Shashi Road [36] => easy and comfortable [40] => never happened [43] => compete for the same lane, freely throwing garbage, changing lanes and turning without lights [44] => without seat belts, driving with slippers, driving, smoking, and drinking, without using children's seats [45] => keep speed, regular maintenance, selection of fuel-saving tires [46] => replacement of exclusive tires, brake set [47] => willing to [48] => replacement of shock absorber, change the exclusive tire [49] => know [50] => The brakes do not slide, the turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed and stability [51] => tire control [52] => male [53] => 3-5 yuan [54] => 1980-1985) [3] => Array ([59] => others ))
Moderator lucky
How can I replace these parameters?
[50] => The brakes do not slide, the turns do not vibrate, the control is sensitive, the control turns accurately, more wear-resistant, the brake distance is short, anti-stash, high-speed stability
I don't quite understand what you mean
I don't quite understand what you mean
A key corresponds to multiple parameters, separated by beans. Is it necessary to traverse more queries?
What about the replacement rules for multiple parameters?
So much data seems messy. can we reduce the amount of data ??
What about the replacement rules for multiple parameters?
In the same way, the keys and values of array 1 are equal to the wjc_bid and wjc_title of array 2 respectively.
foreach($a as $key=>$item) { foreach($item as $k=>$v) { $t = explode(',', $v); foreach($b as $tmp) if($k == $tmp['wjc_bid'] && in_array($tmp['wjc_title'], $t)) $a[$key][$k] .= ':'.$tmp['wjc_dhao']; }}print_r($a);
foreach($a as $key=>$item) { foreach($item as $k=>$v) { $t = explode(',', $v); foreach($b as $tmp) if($k == $tmp['wjc_bid'] && in_array($tmp['wjc_title'], $t)) $a[$key][$k] .= ':'.$tmp['wjc_dhao']; }}print_r($a);
Moderator... It cannot be stopped at all. how can it become a loop for so many times and the Chinese language is not replaced.
Solution
I intentionally wrote this article to check whether your rules are suitable!
I intentionally wrote this article to check whether your rules are suitable!
Rules should be problematic. The data in array 2 is identified in the database based on array 1.
You said it was a replacement, but [43] has more than 1, 3, and 7 values. which one should you replace?
You said it was a replacement, but [43] has more than 1, 3, and 7 values. which one should you replace?
The original format of "competing for the same lane, throwing garbage, changing lanes without lights" is replaced with "1, 3, 7.
You said it was a replacement, but [43] has more than 1, 3, and 7 values. which one should you replace?
Do you want to filter and repeat the array?
foreach($a as $key=>$item) { foreach($item as $k=>$v) { $t = explode(',', $v); foreach($b as $tmp) if($k == $tmp['wjc_bid'] && in_array($tmp['wjc_title'], $t)) $a[$key][$k] = join(','.$tmp['wjc_dhao']); }}print_r($a);
In this case, an error is reported... Solution