function search($term) { global $name, $path, $TweetsPulled, $TweetsAnalyzed, $tweets; $name = $term; $path = "Cache Files/cache" . $name . ".txt"; $id = getID($name); $pic = getProfilePic($id, $name); $max_id = getNextID($path); //gets next tweet to cache, creates file if new cache to be made $tweets = getTweets($name, $id, $TweetsPulled, $max_id); if (!isset($tweets) || count($tweets) < 1) { echo "<script> alert('Bad Twitter Handle'); </script>"; return; } $res = parseData($tweets, $TweetsAnalyzed); }
function main() { $serviceUrl = 'https://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&anliegen[]=%s&Datum=%s&dienstleisterlist=%s'; $officeList = [150230, 122301, 122297, 122294, 122210, 122217, 122219, 122227, 122280, 122282, 122284]; $date = time(); // Change accordingly.... $serviceType = '120686'; // This one is for Almendung // Generate the URL with all the offices we need $url = sprintf($serviceUrl, $serviceType, $date, implode(',', $officeList)); // Fetch the data from our URL $data = fetchData($url); // Parse received data from berlin.de $finalLinks = parseData($data); // Render links for booking if found renderResults($finalLinks); }
function insert($table, $data, $return = true) { $sql = " INSERT INTO " . table($table) . "("; $keys = array_keys($data); $fields = $values = array(); foreach ($keys as $v) { $fields[] = '`' . $v . '`'; $values[] = parseData($data[$v]); } $sql .= implode(',', $fields); $sql .= " ) VALUE ("; $sql .= implode(',', $values); $sql .= "); "; mysql_query($sql); if ($return) { return mysql_insert_id(); } }
function getData($page) { $time_start_phraze = '<b>Погода в Киеве на</b></td><td><span style="font-size:22px;color:black">'; $time_end_phraze = '</span> Kyiv</td>'; $temp_start_phraze = '<td>Температура воздуха </td><td><span class="dat">'; $temp_end_phraze = '°</span></td></tr><tr><td>Температура комфорта </td>'; $comfort_start_phraze = '<td>Температура комфорта </td><td><span class="dat">'; $comfort_end_phraze = '°</span></td></tr><tr><td>Точка росы </td>'; $humidity_start_phraze = '<td>Влажность </td><td><span class="dat">'; $humidity_end_phraze = '%</span></td></tr><tr><td>Давление (на уровне моря) </td>'; $pressure_start_phraze = '<td>Давление (на станции) </td><td><span class="dat">'; $pressure_end_phraze = ' мм.рт.ст.</span></td>'; $wind_start_phraze = '<td>Ветер </td><td><span class="dat">'; $wind_end_phraze = '</span></td></tr><tr><td>Скорость ветра </td>'; $wind_speed_start_phraze = '<td>Скорость ветра </td><td><span class="dat">'; $wind_speed_end_phraze = ' м/с</span></td>'; $weather_start_phraze = '<td>Пог. явления </td><td><span class="dat">'; $weather_end_phraze = '</span></td></tr><tr><td>Облачность </td>'; $result = array("time" => parseData($page, $time_start_phraze, $time_end_phraze), "temp" => (int) parseData($page, $temp_start_phraze, $temp_end_phraze), "comfort" => (int) parseData($page, $comfort_start_phraze, $comfort_end_phraze), "humidity" => (int) parseData($page, $humidity_start_phraze, $humidity_end_phraze), "pressure" => (int) parseData($page, $pressure_start_phraze, $pressure_end_phraze), "wind" => parseData($page, $wind_start_phraze, $wind_end_phraze), "speed" => (int) parseData($page, $wind_speed_start_phraze, $wind_speed_end_phraze), "weather" => parseData($page, $weather_start_phraze, $weather_end_phraze)); return $result; }
function gpu($name, $default = false) { $dq =& get_instance(); $value = parseData(isset($_POST[$name]) ? $dq->input->post($name) : element($name, $dq->query_string)); return $value ? $value : $default; }
/** * Returns array('success'=>true) or array('error'=>'error message') */ function handleUpload($uploadDirectory, $replaceOldFile = FALSE) { if (!is_writable($uploadDirectory)) { return array('error' => "Server error. Upload directory isn't writable."); } if (!$this->file) { return array('error' => 'No files were uploaded.'); } $size = $this->file->getSize(); if ($size == 0) { return array('error' => 'File is empty'); } if ($size > $this->sizeLimit) { return array('error' => 'File is too large'); } $pathinfo = pathinfo($this->file->getName()); $filename = $pathinfo['filename']; //$filename = md5(uniqid()); $ext = $pathinfo['extension']; /* if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){ $these = implode(', ', $this->allowedExtensions); return array('error' => 'File has an invalid extension, it should be one of '. $these . '.'); } */ //$response = $this->file->parseData(); //return array('success'=>true); if (!$replaceOldFile) { /// don't overwrite previous files that were uploaded while (file_exists($uploadDirectory . $filename . '.' . $ext)) { $filename .= rand(10, 99); } } if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) { $response = parseData($uploadDirectory . $filename . '.' . $ext); return array('success' => true, 'response' => $response); } else { return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered'); } }
?> <form method="post" action="" enctype="multipart/form-data"> <input type="file" name="upfile"> <input type="submit" value="Send" name="submit1"> </form> <br><br><br> <?php if (isset($_POST["submit1"])) { $uploadfile = $_FILES["upfile"]["tmp_name"]; $data = file_get_contents($uploadfile); $data = json_decode($data, false, 1024000); unlink($uploadfile); ?> <pre><?php echo implode("\n", parseData($data)); ?> </pre><?php } function parseData($data) { $lines = array(); foreach ($data->log->pages as $page) { $exclude_url = array(); foreach ($data->log->entries as $entrie) { if ($entrie->pageref != $page->id) { continue; } if (!empty($exclude_url[$entrie->request->url])) { continue; }
function parseIntegerData($dataString) { $dataArray = parseData($dataString, 1, 0, 0); return $dataArray; }
#!/usr/bin/env php <?php $d = new DOMDocument(); $d->load($argv[1]); $x = new DOMXPath($d); $x->registerNamespace('svg', 'http://www.w3.org/2000/svg'); $x->registerNamespace('xlink', 'http://www.w3.org/1999/xlink'); $levelW = $x->evaluate('number(//svg:image[@id = "map"]/@width)'); $levelH = $x->evaluate('number(//svg:image[@id = "map"]/@height)'); if (!$levelW || !$levelH || is_nan($levelW) || is_nan($levelH)) { throw new Exception('could not find map dimensions'); } echo "// Level size: {$levelW} x {$levelH}\n"; echo "b2FixtureDef def;"; foreach ($x->evaluate('//svg:path') as $n) { parseData($n->getAttribute('d')); } function parseData($d) { $oldx = -1; $oldy = -1; $startx = -1; $starty = -1; $relative = true; $data = explode(' ', $d); foreach ($data as $pos) { if ($pos == 'M') { $relative = false; continue; } if ($pos == 'm') {
/** * * @param string $tabla * @param array $data * @param array $where * @param resource $link_identifier * @return boolean */ function update($tabla, array $data, array $where, $link_identifier = null) { if (is_null($link_identifier)) { $link_identifier = conexSys(); } $whereArray = $setArray = array(); $whereString = $setString = ''; $tabla = (string) $tabla; $where = (array) $where; $return = false; if (!empty($tabla) && !empty($data) && !empty($where)) { $setArray = parseData($data, $link_identifier); $whereArray = parseData($where, $link_identifier); $setString = implode(', ', $setArray); $whereString = implode(' AND ', $whereArray); $sql = "UPDATE {$tabla} SET {$setString} WHERE {$whereString}"; // W('<br/>'.$sql.'<br/>'); $return = mysql_query($sql, $link_identifier); } return $return; }
<?php $statFile = '/home/caiofior/public_html/webappfiles/log/stat_oper_201625.csv'; $statHandler = fopen($statFile, 'r'); echo $statFile . PHP_EOL; $rawData = fgetcsv($statHandler, 100, ';'); $data = parseData($rawData); do { if (isset($data) && $data['time'] != '') { if ($data['operaz'] == 'risk.negflagpreg2') { print ' INSERT IGNORE INTO aps_stat.operaz (datetime, operaz, time) VALUES ( "' . $data['datetime'] . '", "' . $data['operaz'] . '", ' . $data['time'] . ')'; die; } } $rawData = fgetcsv($statHandler, 100, ';'); $data = parseData($rawData); } while (is_array($rawData)); fclose($statHandler); function parseData($rawData) { if (is_array($rawData) && array_key_exists(2, $rawData) && is_object(date_create_from_format('d/m/Y H:i:s', $rawData[0] . ' ' . $rawData[1]))) { return array('datetime' => date_format(date_create_from_format('d/m/Y H:i:s', $rawData[0] . ' ' . $rawData[1]), 'Y-m-d H:i:s'), 'operaz' => $rawData[3], 'time' => '0' . str_replace(',', '.', str_replace('.', '', $rawData[2]))); } }
function parseData($counterPosition) { global $cookie1, $cookie2, $cookie3, $cookie4, $cookie5; # Store a timestamp of our start point $startTime = mktime(); # Variable used for post backs $dropdowndsAndSearchText = '&ctl00%24ContentPlaceHolder1%24ddlRegion=0&ctl00%24ContentPlaceHolder1%24ddlAlphabet=0&ctl00%24ContentPlaceHolder1%24txtKeywords='; # Get our first set of data $info = ''; $result = ''; getBaseData($info, $result); # We need this for our next two post backs $url = $info['url']; // write here the url of your form # Our base HTML from the healthunit site $html = str_get_html($result); # Require for our Next PostBack(s) $viewstate = $html->find('#__VIEWSTATE'); $viewstate = $viewstate[0]->attr['value']; $validation = $html->find('#__EVENTVALIDATION'); $validation = $validation[0]->attr['value']; # Our looping variable & break variable $break = false; $i = 0; foreach($html->find('#ctl00_ContentPlaceHolder1_tblSearchResults') as $el) { # Our primary loop foreach($el->find('tr') as $row) { # Counter Position Check if ($i < $counterPosition) { $i++; continue; } # TimeCheck # If were over 25minutes - then we break out and restart if ($startTime + 60 * 25 < mktime()) { $break = true; break; } echo 'in our process'; # Increment our counter $i++; # Start processing our records $location = strip_tags($row->childNodes(0)->innertext); //estID is parameter of a tag $location_link = $row->childNodes(0)->find('a'); $location_id = $location_link[0]->attr['estid']; $location_linkid = $location_link[0]->attr['id']; $address = $row->childNodes(1)->innertext; $city = $row->childNodes(2)->innertext; $date = $row->childNodes(4)->innertext; //njs - 10-27-10 - column changes $critical = $row->childNodes(5)->innertext; //njs - 10-27-10 - column changes $noncritical = $row->childNodes(6)->innertext; //njs - 10-27-10 - column changes echo 'location ' . $location . '<br>'; echo 'location link id'.$location_linkid.'<br />'; echo 'location link ' . $location_link . '<br />'; echo 'location id ' . $location_id . '<br>'; echo 'address ' . $address . '<br>'; echo 'city ' . $city . '<br>'; echo 'date ' . $date . '<br>'; echo 'critical ' . $critical . '<br>'; echo 'noncritical ' . $noncritical . '<br>'; if ($date != '') { $inspected = date('Y-m-d', strtotime($date)); //njs - 10-28-10 //reset closures if reinspections have occurred boolReInspection($location_id, $inspected); } else { $inspected = '0000-00-00'; } $location_id = updateLocation($location, $address, $city, $inspected, $critical, $noncritical); //njs - 10-28-10 //update inspection was returning false positives on infractions //changed to only check inspection date //$update_inspect = boolUpdateInspection($location_id, $inspected, $critical, $noncritical); $update_inspect = boolUpdateInspection($location_id, $inspected); if ($update_inspect) { try { # Get any of the inspection information $ch = curl_init(); // Initiating the Curl Handler curl_setopt($ch, CURLOPT_URL,$url); // Url a donde se va a postear. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); //I set the user Agent. In this case is Firefox 2 browser curl_setopt($ch, CURLOPT_FAILONERROR, 1); //finish in case of error curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirections curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Return the result page in a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout. curl_setopt($ch, CURLOPT_POST, 1); // I set the POST Method curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie3); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie4); $post = '__EVENTTARGET='.str_replace('_','%24',$location_linkid); $post.= '&__EVENTARGUMENT=&__VIEWSTATE='.urlencode($viewstate); $post.= '&__EVENTVALIDATION='.urlencode($validation); $post.= $dropdowndsAndSearchText; curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //change it with your own field name and value $result2 = curl_exec($ch); // Execute and send the data. $info = curl_getinfo($ch); curl_close($ch); # Parse the results & loop through each inspection date $html2 = str_get_html($result2); $viewstate2 = $html2->find('#__VIEWSTATE'); $viewstate2 = $viewstate2[0]->attr['value']; $validation2 = $html2->find('#__EVENTVALIDATION'); $validation2 = $validation2[0]->attr['value']; $divLocation2 = strpos($result2, '<div id="ctl00_ContentPlaceHolder1_pnlViolations"'); $pos2 = substr($result2, $divLocation2, strpos($result2, '</div>', $divLocation2) - $divLocation2); $html2->clear(); unset($html2); $htmldata2 = str_get_html('<html><body>'.$pos2.'</body></html>'); $skip2 = false; } catch (Exception $e) { error_log('Error processing document ' . $e->getMessage()); die('Error processing document ' . $e->getMessage()); } echo '<br/>process rows '.date('h:i:s'); foreach($htmldata2->find('tr') as $row2) { # Skip the header row if (!$skip2) { $skip2 = true; continue; } # Grab our data $inspectionLink = $row2->childNodes(0)->find('a'); if ($inspectionLink[0]->innertext != '') { $inspectionDate = date('Y-m-d', strtotime($inspectionLink[0]->innertext)); } else { $inspectionDate = '0000-00-00'; } $estid = $inspectionLink[0]->attr['estid']; $inspectionId = $inspectionLink[0]->attr['inspectionid']; $inspectionLinkId = $inspectionLink[0]->attr['id']; $inspectionType = $row2->childNodes(2)->innertext; // rtraction djm - Nov.2 2010 - blank row added $critical = $row2->childNodes(3)->innertext; // rtraction djm - Nov.2 2010 - blank row added $nonCritical = $row2->childNodes(4)->innertext; // rtraction djm - Nov.2 2010 - blank row added # Testing echo 'Inspecd:'.$inspectionDate.'<br />'; echo 'ESTID:'.$estid.'<br />'; echo 'InspecId:'.$inspectionId.'<br />'; echo 'InspecT:'.$inspectionType.'<br />'; echo 'Critical:'.$critical.'<br />'; echo 'NonCritical:'.$nonCritical.'<br />'; echo '<br />'; # Grab the text $ch = curl_init(); // Initiating the Curl Handler curl_setopt($ch, CURLOPT_URL,$url); // Url a donde se va a postear. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); //I set the user Agent. In this case is Firefox 2 browser curl_setopt($ch, CURLOPT_FAILONERROR, 1); //finish in case of error curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirections curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Return the result page in a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout. curl_setopt($ch, CURLOPT_POST, 1); // I set the POST Method curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie4); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie5); $post = '__EVENTTARGET='.str_replace('_','%24',$inspectionLinkId); $post.= '&__EVENTARGUMENT=&__VIEWSTATE='.urlencode($viewstate2); $post.= '&__EVENTVALIDATION='.urlencode($validation2); $post.= $dropdowndsAndSearchText; curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //change it with your own field name and value $result3 = curl_exec($ch); // Execute and send the data. $info = curl_getinfo($ch); curl_close($ch); # Parse the results & loop through each item $divLocation3 = strpos($result3, '<div id="ctl00_ContentPlaceHolder1_pnlViolationDetails"'); $pos3 = substr($result3, $divLocation3, strpos($result3, '</div>', $divLocation3) - $divLocation3); $htmldata3 = str_get_html('<html><body>'.$pos3.'</body></html>'); $skip3 = false; foreach($htmldata3->find('tr') as $row3) { # Skip any header rows if ($row3->class == "inspectionTableHeader") { continue; } # Grab our data for all normal rows if (isset($row3->childNodes(2)->innertext)) { //severity can be critical, noncritical, satisfactory $severity = strip_tags($row3->childNodes(0)->innertext); $desc = $row3->childNodes(1)->innertext; $resultText = $row3->childNodes(2)->innertext; # Testing echo 'Severity:'.$severity.'<br />'; echo 'Desc:'.$desc.'<br />'; echo 'Res:'.$resultText.'<br />'; echo '<br />'; $details = ''; $category = ''; if ($desc != '') { $desc = strip_tags($desc); $failPos = stripos($desc, 'Fail'); $category = substr($desc, 0, $failPos); $details = substr($desc, $failPos, strlen($desc)); } # Update details in db updateInspection($location_id, $inspectionDate, $severity, $resultText, $details, $category, $inspected); } else { // Do we have an order 13? $text = $row3->childNodes(0)->innertext; if (strpos(strtolower($text), 'section 13 order served') !== FALSE) { echo 'Order 13 Served!<br />'; // We found an Order 13 - so lets capture that information updateInspection($location_id, $inspectionDate, 'Closed', 'No', strip_tags($text), 'Order 13 Served', $inspected); } else if (strpos(strtolower($text), 'section 13 order revoked') !== FALSE) { echo 'Order 13 Revoked!<br />'; // We found an Order 13 - so lets capture that information updateInspection($location_id, $inspectionDate, 'Closed', 'No', strip_tags($text), 'Order 13 Revoked', $inspected); } else { echo 'No infractions - record note!<br />'; // We record a simple note as there was no infractions updateInspection($location_id, $inspectionDate, 'Note', 'No', ' ', strip_tags($text), $inspected); } } } $htmldata3->clear(); unset($htmldata3); # Only process one inspection ///break; Process all inspections - Aug. 5, 2010 - rtraction djm } $htmldata2->clear(); unset($htmldata2); } } # We've hit our timelimit above so we want to break out if ($break) { break; } } $html->clear(); unset($html); // updated log table if (!$break) { updateLog(); } else { # We hit a time block above and broke out of our loops # We're starting the process again but jumping ahead parseData($i); } }
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = curl_exec($ch); curl_close($ch); return $result; } function parseData($result) { $json = array(); foreach ($result->data as $post) { $d = array('id' => $post->id, 'tags' => $post->tags, 'images' => $post->images, 'type' => $post->type, 'location' => $post->location->name, 'link' => $post->link, 'timestamp' => $post->created_time); array_push($json, $d); } return $json; } $filename = "./data/" . date("mdY") . "_insta.json"; function cacheExists() { $filename = "./data/" . date("mdY") . "_instacache.json"; return file_exists($filename); } if (cacheExists()) { $json = file_get_contents($filename); } else { $result = fetchData("https://api.instagram.com/v1/users/233559774/media/recent/?access_token=1471.2529a78.f57268a06ada4272a64c98c3a70803da"); $result = json_decode($result); $json = parseData($result); file_put_contents($filename, json_encode($json)); } header('Content-Type: application/json'); echo json_encode($json);
function getCalendarData() { global $cache, $debugMode; if ($cache) { $data = getCacheFileData(); } else { $data = getOnlineData(); } parseData($data); if ($debugMode) { echo "<p><strong>Done!</strong></p>"; } }
<?php include_once 'auth_connect.php'; include_once 'data_connect.php'; include_once 'functions.php'; sec_session_start(); // Our custom secure way of starting a PHP session. if (isset($_POST['username'], $_POST['p'])) { $username = $_POST['username']; $password = $_POST['p']; // The hashed password. // Login successfull if (login($username, $password, $mysqli) == true) { // Send the formated data over echo parseData($mysqli, $mysqli_content); } else { // Incorrect values sent echo false; } } else { // The correct POST variables were not sent to this page. echo false; }
$itemObj->sellerInfo->positiveFeedbackPercent = (string) $child->sellerInfo->positiveFeedbackPercent; $itemObj->sellerInfo->sellerUserName = (string) $child->sellerInfo->sellerUserName; $itemObj->sellerInfo->feedbackScore = (string) $child->sellerInfo->feedbackScore; $itemObj->sellerInfo->sellerStoreName = (string) $child->storeInfo->storeName; $itemObj->sellerInfo->sellerStoreURL = (string) $child->storeInfo->storeURL; $itemObj->sellerInfo->feedbackRatingStar = (string) $child->sellerInfo->feedbackRatingStar; $itemObj->sellerInfo->topRatedSeller = (string) $child->sellerInfo->topRatedSeller; //shippingInfo class $itemObj->shippingInfo->oneDayShippingAvailable = (string) $child->shippingInfo->oneDayShippingAvailable; $itemObj->shippingInfo->shippingType = (string) $child->shippingInfo->shippingType; $itemObj->shippingInfo->expeditedShipping = (string) $child->shippingInfo->expeditedShipping; $itemObj->shippingInfo->expeditedShipping = (string) $child->shippingInfo->expeditedShipping; $itemObj->shippingInfo->returnsAccepted = (string) $child->returnsAccepted; $itemObj->shippingInfo->handlingTime = (string) $child->shippingInfo->handlingTime; foreach ($child->shippingInfo->children() as $locations) { if ($locations->getName() == "shipToLocations") { $itemObj->shippingInfo->shipToLocations = $itemObj->shippingInfo->shipToLocations . $locations . ','; } } $itemObj->shippingInfo->shipToLocations = substr($itemObj->shippingInfo->shipToLocations, 0, -1); $mainObj->item1[$i] = $itemObj; $i = $i + 1; } return json_encode($mainObj); } } generateXML(); echo parseData(); ?>
function collectData($pre, $post, $split, $data) { $list = parseData($pre, $post, $data); $list = explode($split, $list); return $list; }
function handleReadData($sock, $str_len, $type) { $data = socket_read($sock, $str_len); $bulk = parseData($data); $cmd = array_shift($bulk); $result = false; $handler_func = "{$cmd}{$type}Handler"; if (function_exists($handler_func)) { $result = call_user_func_array($handler_func, array($bulk)); // 这个函数写错,老出问题 } else { $result = $data; } return $result; }
<?php require_once SERVER_ROOT . '/module/query_create/module.php'; require_once SERVER_ROOT . '/module/query_run/module.php'; require_once SERVER_ROOT . '/module/parse_data/module.php'; $m_axes = json_decode($_POST["m_axes"]); $query = queryCreate($m_axes); $query_results = queryRun($query); // $round_count_min = $m_axes->x_axis->round_count_min; $round_count = $m_axes->x_axis->round_count; $data = parseData($query_results, $round_count); $output = new stdClass(); $output->query = $query; $output->data_heat = $data->data_heat; $output->data_round = $data->data_round; $output->x_datatype = 'linear'; echo json_encode($output);
$ldap->bind(); $ldap->search("ugentdormpostaladdress=*HOME*"); $data = $ldap->get_entries(); $_SESSION['ldapData'] = $data; } else { $data = $_SESSION['ldapData']; } //voor de statistiekjes $aantal = sizeof($data); $failed = 0; $home = 0; $kamer = 0; //we itereren over de resultset foreach ($data as $rij) { //we parsen de data $parse = parseData($rij); //we controleren de data if (($parse['home'] == "" || strlen($parse['kamer']) != 13) && $parse['gebruikersnaam'] != "") { //er is iets fout, dus we outputten de data voor verder onderzoek echo "<pre>"; print_r($parse); print_r($rij); echo "</pre>"; $failed++; if ($parse['home'] == "") { $home++; } if (strlen($parse['kamer']) != 13) { $kamer++; } }
$product = mapProduct($columns, getMapping()); $products[] = $product; } return $products; } function mapProduct($columns, $mapping) { $product = []; foreach ($columns as $key => $value) { if (isset($mapping[$key + 1])) { $attribute = $mapping[$key + 1]; $product[$attribute] = $value; } } return $product; } function writeToStorage($products) { // извращение :) $filesContents = array_map(function ($product) { $contents = ''; foreach ($product as $key => $value) { $contents .= sprintf("%s:%s\n", $key, $value); } return $contents; }, $products); var_dump($filesContents); } $lines = readCsvFile('products.csv'); $products = parseData($lines); writeToStorage($products);