Jean-Baptiste DRAVET

All generations.

generate functionFri, 27 Jan 2023

import csv from local file and save it into an array

function getcsv($filename, $delimiter=',') { if(!file_exists($filename) || !is_readable($filename)) return FALSE; $header = NULL; $data = array(); if (($handle = fopen($filename, 'r')) !== FALSE) { while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) { if(!$header) $header = $row; else $data[] = array_combine($header, $row); } fclose($handle); } return $data; }

PHP
View
generate functionFri, 27 Jan 2023

import csv from local file

function readCSV($csvFile){ // name the function and set the parameter $file_handle = fopen($csvFile, 'r'); // open the csv file while (!feof($file_handle) ) { // loop through the csv file $line_of_text[] = fgetcsv($file_handle, 1024); // extract each line of the csv file } fclose($file_handle); // close the csv file return $line_of_text; // return the array } // Set path to CSV file $csvFile = 'test.csv'; $csv = readCSV($csvFile); // output the result of the function

PHP
View
css from descriptionTue, 17 Jan 2023

create a popup who disappear after 5 seconds

.popup { /* Set the position of the popup box */ position: relative; display: inline-block; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* The actual popup */ .popup .popuptext { visibility: hidden; width: 160px; background-color: #555; color: #fff; text-align: center; border-radius: 6px; padding: 8px 0; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -80px; } /* Popup arrow */ .popup .popuptext::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border

Questions about programming?Chat with your personal AI assistant