codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php /** * This file is part of the array_column library * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @copyright Copyright (c) Ben Ramsey (http://benramsey.com) * @license http://opensource.org/licenses/MIT MIT */ if (!function_exists('array_column')) { /** * Returns the values from a single column of the input array, identified by * the $columnKey. * * Optionally, you may provide an $indexKey to index the values in the returned * array by the values from the $indexKey column in the input array. * * @param array $input A multi-dimensional array (record set) from which to pull * a column of values. * @param mixed $columnKey The column of values to return. This value may be the * integer key of the column you wish to retrieve, or it * may be the string key name for an associative array. * @param mixed $indexKey (Optional.) The column to use as the index/keys for * the returned array. This value may be the integer key * of the column, or it may be the string key name. * @return array */ function array_column($input = null, $columnKey = null, $indexKey = null) { // Using func_get_args() in order to check for proper number of // parameters and trigger errors exactly as the built-in array_column() // does in PHP 5.5. $argc = func_num_args(); $params = func_get_args(); if ($argc < 2) { trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); return null; } if (!is_array($params[0])) { trigger_error( 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given', E_USER_WARNING ); return null; } if (!is_int($params[1]) && !is_float($params[1]) && !is_string($params[1]) && $params[1] !== null && !(is_object($params[1]) && method_exists($params[1], '__toString')) ) { trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); return false; } if (isset($params[2]) && !is_int($params[2]) && !is_float($params[2]) && !is_string($params[2]) && !(is_object($params[2]) && method_exists($params[2], '__toString')) ) { trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); return false; } $paramsInput = $params[0]; $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; $paramsIndexKey = null; if (isset($params[2])) { if (is_float($params[2]) || is_int($params[2])) { $paramsIndexKey = (int) $params[2]; } else { $paramsIndexKey = (string) $params[2]; } } $resultArray = array(); foreach ($paramsInput as $row) { $key = $value = null; $keySet = $valueSet = false; if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { $keySet = true; $key = (string) $row[$paramsIndexKey]; } if ($paramsColumnKey === null) { $valueSet = true; $value = $row; } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { $valueSet = true; $value = $row[$paramsColumnKey]; } if ($valueSet) { if ($keySet) { $resultArray[$key] = $value; } else { $resultArray[] = $value; } } } return $resultArray; } } /** * Expected result (Line 893) * $line = array( * 0 => array ( * 'stop_code' => '1518', * 'stop_name' => 'Place Jacques-Cartier', * 'stop_desc' => '<p>Entrée en bas, côté stationnements</p>', * 'stop_city' => 'gaspe', * 'arrival' => array ( * 0 => '07:45', * 1 => '15:45', * 1 => '—', * ), * 1 => array ( * 'stop_code' => '1578', * 'stop_name' => 'Pouvoir des Mots', * 'stop_desc' => '', * 'stop_city' => 'gaspe', * 'arrival' => array ( * 0 => '07:48', * 1 => '—', * 1 => '16:29', * ) * ) **/ $tabs_content = array ( 0 => array ( 'trip_headsign' => 'Gaspé vers Wakeham, Sunny Bank, York Ouest et Gaspé', 'trip_slug' => '23-c', 'service_id' => '166', 'stops' => array ( 0 => array ( 'stop_code' => '1578', 'stop_name' => 'Pouvoir des Mots', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:29', ), 1 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:29', ), 2 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:29', ), 3 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:29', ), 4 => array ( 'stop_code' => '1583', 'stop_name' => 'Maison des jeunes', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:30', ), 5 => array ( 'stop_code' => '1581', 'stop_name' => 'Dépanneur du Coin', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:31', ), 6 => array ( 'stop_code' => '1580', 'stop_name' => 'Pavillon Mgr Ross', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:32', ), 7 => array ( 'stop_code' => '1582', 'stop_name' => 'Brico-déco', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:37', ), 8 => array ( 'stop_code' => '1583', 'stop_name' => 'Maison des jeunes', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:38', ), 9 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:39', ), 10 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:40', ), 11 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '16:42', ), 12 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p>', 'stop_city' => 'gaspe', 'arrival' => '16:47', ), ), ), 1 => array ( 'trip_headsign' => 'Gaspé vers Wakeham, Sunny Bank, York Ouest et Gaspé', 'trip_slug' => '23-b', 'service_id' => '166', 'stops' => array ( 0 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p> ', 'stop_city' => 'gaspe', 'arrival' => '15:45', ), 1 => array ( 'stop_code' => '1519', 'stop_name' => 'Intersection route 198 / rue Kelly', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:00', ), 2 => array ( 'stop_code' => '1520', 'stop_name' => 'Centre Jeunesse', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:01', ), 3 => array ( 'stop_code' => '1521', 'stop_name' => 'Dépanneur du Versant', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:01', ), 4 => array ( 'stop_code' => '1522', 'stop_name' => 'Garderie CPE Voyage de mon enfance', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:01', ), 5 => array ( 'stop_code' => '1523', 'stop_name' => 'Intersection route 198 / rue Coffin', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:02', ), 6 => array ( 'stop_code' => '1524', 'stop_name' => '553, montée de Wakeham', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:03', ), 7 => array ( 'stop_code' => '1525', 'stop_name' => 'École Eastern Shore', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:04', ), 8 => array ( 'stop_code' => '1526', 'stop_name' => 'Intersection route 198 / boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '16:04', ), 9 => array ( 'stop_code' => '1527', 'stop_name' => 'Intersection boulevard York Ouest / rue Sunny-Bank', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:08', ), 10 => array ( 'stop_code' => '1528', 'stop_name' => '1014, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:09', ), 11 => array ( 'stop_code' => '1529', 'stop_name' => '649, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:09', ), 12 => array ( 'stop_code' => '1530', 'stop_name' => '618, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:10', ), 13 => array ( 'stop_code' => '1531', 'stop_name' => '568, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:15', ), 14 => array ( 'stop_code' => '1532', 'stop_name' => '410, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:16', ), 15 => array ( 'stop_code' => '1533', 'stop_name' => '333, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:16', ), 16 => array ( 'stop_code' => '1534', 'stop_name' => 'Intersection rue Leclerc / rue Patterson', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:16', ), 17 => array ( 'stop_code' => '1535', 'stop_name' => 'Intersection rue Patterson / rue Miller', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:16', ), 18 => array ( 'stop_code' => '1536', 'stop_name' => 'Intersection rue Riverin / rue Leclerc', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:17', ), 19 => array ( 'stop_code' => '1537', 'stop_name' => 'Intersection rue Riverin / York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:18', ), 20 => array ( 'stop_code' => '1538', 'stop_name' => 'Bureau de poste', 'stop_desc' => '<p>"Harbour"</p> ', 'stop_city' => 'york', 'arrival' => '16:18', ), 21 => array ( 'stop_code' => '1540', 'stop_name' => 'Hôpital', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:19', ), 22 => array ( 'stop_code' => '1541', 'stop_name' => 'Pavillon Cantin et CLSC', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:19', ), 23 => array ( 'stop_code' => '1571', 'stop_name' => 'Irving Couche Tard 24H', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '16:23', ), 24 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p> ', 'stop_city' => 'gaspe', 'arrival' => '16:26', ), ), ), 2 => array ( 'trip_headsign' => 'Gaspé vers Wakeham, Sunny Bank, York Ouest et Gaspé', 'trip_slug' => '23-a', 'service_id' => '166', 'stops' => array ( 0 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p> ', 'stop_city' => 'gaspe', 'arrival' => '07:45', ), 1 => array ( 'stop_code' => '1578', 'stop_name' => 'Pouvoir des Mots', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:48', ), 2 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:48', ), 3 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:49', ), 4 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:50', ), 5 => array ( 'stop_code' => '1583', 'stop_name' => 'Maison des jeunes', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:51', ), 6 => array ( 'stop_code' => '1581', 'stop_name' => 'Dépanneur du Coin', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:52', ), 7 => array ( 'stop_code' => '1580', 'stop_name' => 'Pavillon Mgr Ross', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:54', ), 8 => array ( 'stop_code' => '1582', 'stop_name' => 'Brico-déco', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:55', ), 9 => array ( 'stop_code' => '1583', 'stop_name' => 'Maison des jeunes', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:56', ), 10 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:57', ), 11 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:58', ), 12 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '07:59', ), 13 => array ( 'stop_code' => '1519', 'stop_name' => 'Intersection route 198 / rue Kelly', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:00', ), 14 => array ( 'stop_code' => '1520', 'stop_name' => 'Centre Jeunesse', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:01', ), 15 => array ( 'stop_code' => '1521', 'stop_name' => 'Dépanneur du Versant', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:01', ), 16 => array ( 'stop_code' => '1522', 'stop_name' => 'Garderie CPE Voyage de mon enfance', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:01', ), 17 => array ( 'stop_code' => '1523', 'stop_name' => 'Intersection route 198 / rue Coffin', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:02', ), 18 => array ( 'stop_code' => '1524', 'stop_name' => '553, montée de Wakeham', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:03', ), 19 => array ( 'stop_code' => '1525', 'stop_name' => 'École Eastern Shore', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:04', ), 20 => array ( 'stop_code' => '1526', 'stop_name' => 'Intersection route 198 / boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'wakeham', 'arrival' => '08:04', ), 21 => array ( 'stop_code' => '1527', 'stop_name' => 'Intersection boulevard York Ouest / rue Sunny-Bank', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:11', ), 22 => array ( 'stop_code' => '1528', 'stop_name' => '1014, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:12', ), 23 => array ( 'stop_code' => '1529', 'stop_name' => '649, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:13', ), 24 => array ( 'stop_code' => '1530', 'stop_name' => '618, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:14', ), 25 => array ( 'stop_code' => '1531', 'stop_name' => '568, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:15', ), 26 => array ( 'stop_code' => '1532', 'stop_name' => '410, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:16', ), 27 => array ( 'stop_code' => '1533', 'stop_name' => '333, boulevard York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:17', ), 28 => array ( 'stop_code' => '1534', 'stop_name' => 'Intersection rue Leclerc / rue Patterson', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:18', ), 29 => array ( 'stop_code' => '1535', 'stop_name' => 'Intersection rue Patterson / rue Miller', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:19', ), 30 => array ( 'stop_code' => '1536', 'stop_name' => 'Intersection rue Riverin / rue Leclerc', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:20', ), 31 => array ( 'stop_code' => '1537', 'stop_name' => 'Intersection rue Riverin / York Ouest', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:20', ), 32 => array ( 'stop_code' => '1538', 'stop_name' => 'Bureau de poste', 'stop_desc' => '<p>"Harbour"</p> ', 'stop_city' => 'york', 'arrival' => '08:21', ), 33 => array ( 'stop_code' => '1540', 'stop_name' => 'Hôpital', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:22', ), 34 => array ( 'stop_code' => '1541', 'stop_name' => 'Pavillon Cantin et CLSC', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:23', ), 35 => array ( 'stop_code' => '1571', 'stop_name' => 'Irving Couche Tard 24H', 'stop_desc' => '', 'stop_city' => 'york', 'arrival' => '08:25', ), 36 => array ( 'stop_code' => '1576', 'stop_name' => 'Intersection rue Chrétien / J. Cartier', 'stop_desc' => '<p>Arrêt près du Jean-Coutu</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:28', ), 37 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:35', ), 38 => array ( 'stop_code' => '1578', 'stop_name' => 'Pouvoir des Mots', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:36', ), 39 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:37', ), 40 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:39', ), 41 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:41', ), 42 => array ( 'stop_code' => '1513', 'stop_name' => 'Radio-Gaspésie', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:43', ), 43 => array ( 'stop_code' => '1509', 'stop_name' => 'Garage B. Dodge Chrysler', 'stop_desc' => '<p>70, rue Jacques Cartier</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:44', ), 44 => array ( 'stop_code' => '1508', 'stop_name' => 'École C.E. Pouliot et Musée de la Gaspésie', 'stop_desc' => '<p>L\'arrêt se fait selon à l\'école ou au musée, selon la direction du trajet</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:45', ), 45 => array ( 'stop_code' => '1507', 'stop_name' => 'CFE Desjardins', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:46', ), 46 => array ( 'stop_code' => '1585', 'stop_name' => 'Foyer Notre-Dame', 'stop_desc' => '<p>Entrée principale</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:47', ), 47 => array ( 'stop_code' => '1509', 'stop_name' => 'Garage B. Dodge Chrysler', 'stop_desc' => '<p>70, rue Jacques Cartier</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:48', ), 48 => array ( 'stop_code' => '1510', 'stop_name' => 'Cégep', 'stop_desc' => '<p>Cégep de la Gaspésie, campus de Gaspé</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:49', ), 49 => array ( 'stop_code' => '1513', 'stop_name' => 'Radio-Gaspésie', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:50', ), 50 => array ( 'stop_code' => '1514', 'stop_name' => 'Intersection rue de la Cathédrale / rue Mgr Leblanc', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:51', ), 51 => array ( 'stop_code' => '1515', 'stop_name' => 'Hôtel des Commandants', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:52', ), 52 => array ( 'stop_code' => '1517', 'stop_name' => 'Accueil Blanche-Goulet / Auberge W. Wakeham', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:53', ), 53 => array ( 'stop_code' => '1578', 'stop_name' => 'Pouvoir des Mots', 'stop_desc' => '', 'stop_city' => 'gaspe', 'arrival' => '08:54', ), 54 => array ( 'stop_code' => '1518', 'stop_name' => 'Place Jacques-Cartier', 'stop_desc' => '<p>Entrée en bas, côté stationnements</p> ', 'stop_city' => 'gaspe', 'arrival' => '08:55', ), ), ), ); //Put Trips in order $tabs_content = array_reverse($tabs_content); $table_headers = NULL; $line_count = 0; $count_trips_stops = array(); foreach ($tabs_content as $column) { // Set headers $table_headers[]['service_id'] = $column['service_id']; // Count trips for future compare foreach($column['stops'] as $stop) { if (array_key_exists($column['trip_slug'], $count_trips_stops)) { $count_trips_stops[$column['trip_slug']]++; } else { $count_trips_stops[$column['trip_slug']] = 0; } } } // Define loop max with the highest total of stop by trip $max_lines = max($count_trips_stops); //54 MAX $trip_slug = array_search($max_lines, $count_trips_stops); //23-a WHO $trip_slug_position = array_search($trip_slug, array_column($tabs_content, 'trip_slug')); //0 POSITION $trip_slug_max = count(array_column($tabs_content, 'trip_slug')); //3 HOW MANY //Create an array with all the stop code $stops_code_list = array(); $stops_code_list_tmp = array(); foreach ($tabs_content[$trip_slug_position] as $column) { if (is_array($column)) { $stops_code_list = $column; } } $line_count = 0; while ($line_count<$max_lines) { for($i=0; $i<$trip_slug_max; $i++) { if (isset($tabs_content[$i]['stops'][$line_count]) && ($stops_code_list[$line_count]['stop_code'] == $tabs_content[$i]['stops'][$line_count]['stop_code'])) { echo $stops_code_list[$line_count]['stop_code'] .' == '. $tabs_content[$i]['stops'][$line_count]['stop_code'] .'<br>'; $stop_key = true; } else { if (isset($tabs_content[$i]['stops'][$line_count])) { echo $stops_code_list[$line_count]['stop_code'] .' != '. $tabs_content[$i]['stops'][$line_count]['stop_code'] .'<br>'; } else { echo 'Out of offset<br>'; } $stop_key = false; } if ($stop_key) { $line[$line_count]['code'] = $tabs_content[$i]['stops'][$line_count]['stop_code']; $line[$line_count]['city'] = $tabs_content[$i]['stops'][$line_count]['stop_city']; $line[$line_count]['name'] = $tabs_content[$i]['stops'][$line_count]['stop_name']; $line[$line_count]['time'][] = $tabs_content[$i]['stops'][$line_count]['arrival']; } else { $line[$line_count]['code'] = $tabs_content[$trip_slug_position]['stops'][$line_count]['stop_code']; $line[$line_count]['city'] = $tabs_content[$trip_slug_position]['stops'][$line_count]['stop_city']; $line[$line_count]['name'] = $tabs_content[$trip_slug_position]['stops'][$line_count]['stop_name']; $line[$line_count]['time'][] = '—'; } } $line_count++; } print_r($line);
Private
[
?
]
Run code
Submit