Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $priceListTable = html_entity_decode($_GET['priceList']);
- $pattern = "/[\s\n\r\t]*<tr>[\s\n\r\t]*<td>[\s\n\r]*(.+?)[\s\n\r\t]*<\/td>[\s\n\r\t]*<td>[\s\n\r\t]*(.+?)[\s\n\r\t]*<\/td>[\s\n\r\t]*<td>[\s\n\r\t]*(\d+\.?\d{0,2})[\s\n\r\t]*<\/td>[\s\n\r\t]*<td>[\s\n\r\t]*(.+?)[\s\n\r\t]*<\/td>[\s\n\r\t]*<\/tr>/";
- preg_match_all($pattern, $priceListTable, $matches);
- $priceList = array();
- for ($i=0; $i < sizeof($matches[2]) ; $i++) {
- if(!isset($priceList[$matches[2][$i]])){
- $priceList[$matches[2][$i]] = [];
- }
- $temp = array(
- "product" => $matches[1][$i],
- "price" => $matches[3][$i],
- "currency" => $matches[4][$i]
- );
- $priceList[$matches[2][$i]][] = $temp;
- }
- ksort($priceList);
- $temp = json_encode($priceList);
- echo $temp;
- foreach ($priceList as $key => $category) {
- foreach ($category as $key=>$product) {
- $outputArr[$key] = $product['product'];
- }
- array_multisort($outputArr, SORT_ASC, $category);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement