Curs Php-mysql

- parseCSV e o clasa PHP gratuita pentru citire si scriere usor a datelor in format CSV.
- Download parseCSV 0.4.3 beta.

Caracteristici

• Suporta valori inchise, virgule inchise, ghilimele duble si linii noi.
• Detectare automata caracter de delimitare.
• Sortare /filtrare dupa anumite campuri /coloane.
• Comenzi SQL de baza, limitare date returnate.
• Retine datele CSV in array, transforma array in format CSV.
• Detectare erori intr-un mod "inteligent", dar depinde si de structura continutului CSV.
• Suporta conversia caracterelor, folosind functia PHP iconv().

Exemple
- Urmatoarele doua exemple folosesc acest CSV, salvat in "books.csv":
rating,title,author,type,asin,tags,review
0,The Third Secret,Steve Berry,Book,0340899263,,need to find time to read this book
3,The Last Templar,Raymond Khoury,Book,0752880705,,
4,The Da Vinci Code (Hardcover),Dan Brown,"     Book     ",0385504209,book movie danbrown bestseller davinci,

1. Citire fisier CSV (cu auto-detectare caracter de delimitare) si retine datele in array:
<?php
// include clasa parseCSV
include('parsecsv/parsecsv.class.php');

// creaza obiect parseCSV
$csv = new parseCSV();

// Citeste si analizeaza 'books' folosind detectarea automata a delimitarii
$csv->auto('books.csv');

// daca stiti caracterul de delimitare (daca nu e cel standard, virgula ','), il puteti adauga
// $csv->delimiter = "\t"; // delimitator tab

$csvdata = $csv->data; // retine datele csv in array

// afiseaza rezultatul
echo '<pre>';
print_r($csvdata);
echo '</pre>';
?>

Rezulta:
Array
(
 [0] => Array
 (
 [rating] => 0
 [title] => The Third Secret
 [author] => Steve Berry
 [type] => Book
 [asin] => 0340899263
 [tags] => 
 [review] => need to find time to read this book
 )
 [1] => Array
 (
 [rating] => 3
 [title] => The Last Templar
 [author] => Raymond Khoury
 [type] => Book
 [asin] => 0752880705
 [tags] => 
 [review] => 
 )
 [2] => Array
 (
 [rating] => 4
 [title] => The Da Vinci Code (Hardcover)
 [author] => Dan Brown
 [type] => Book 
 [asin] => 0385504209
 [tags] => book movie danbrown bestseller davinci
 [review] => 
 )
)

2. Citeste fisierul CSV, sorteaza datele dupa "title".
<?php
// include clasa parseCSV.
include('parsecsv/parsecsv.class.php');

// creaza obiect parseCSV
$csv = new parseCSV();

$csv->sort_by = 'title';

// Citeste si analizeaza 'books' folosind detectarea automata a delimitarii
$csv->auto('books.csv');

$csvdata = $csv->data; // retine datele din csv in array

// afiseaza rezultatul
echo '<pre>';
print_r($csvdata);
echo '</pre>';
?>

Rezulta:
Array
(
 [The Da Vinci Code (Hardcover)] => Array
 (
 [rating] => 4
 [title] => The Da Vinci Code (Hardcover)
 [author] => Dan Brown
 [type] => Book 
 [asin] => 0385504209
 [tags] => book movie danbrown bestseller davinci
 [review] => 
 )
 [The Last Templar] => Array
 (
 [rating] => 3
 [title] => The Last Templar
 [author] => Raymond Khoury
 [type] => Book
 [asin] => 0752880705
 [tags] => 
 [review] => 
 )
 [The Third Secret] => Array
 (
 [rating] => 0
 [title] => The Third Secret
 [author] => Steve Berry
 [type] => Book
 [asin] => 0340899263
 [tags] => 
 [review] => need to find time to read this book
 )
)

3. Transforma array 2D in CSV, si-l trimite ca fisier la browser ca sa fie descarcat.
<?php
// include clasa parseCSV.
include('parsecsv/parsecsv.class.php');

$csvHeader = array('category', 'link'); // csv header

// array bi-dimensional cu datele pt csv (dupa cum e setat la header)
$csvData = array(
 array('tutorials', 'http://www.coursesweb.net/php-mysql/tutorials_t'),
 array('scripts', 'http://www.coursesweb.net/php-mysql/scripts_s2'),
 array('resources', 'http://www.coursesweb.net/php-mysql/download_l2')
 );

// creaza obiect parseCSV.
$csv = new parseCSV();

// transforma array-ul bi-dimensional in CSV, si-l trimite ca fisier la browser ca sa fie descarcat
// (nume_fisier, date-csv, csv-header, delimitator)
$csv->output('coursesweb.csv', $csvData, $csvHeader, ',');
?>

Rezulta acest CSV:
category,link
tutorials,http://www.coursesweb.net/php-mysql/tutorials_t
scripts,http://www.coursesweb.net/php-mysql/scripts_s2
resources,http://www.coursesweb.net/php-mysql/download_l2

- In arhiva cu clasa parseCSV veti gasi mai multe exemple.
parseCSV Web Site.

Un Test simplu in fiecare zi

HTML
CSS
JavaScript
PHP-MySQL
Engleza
Spaniola
Ce tag se foloseste pentru a adauga liste in elemente <ul> si <ol>?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://www.marplo.net/html/</li>
</ul>
Care valoare a proprietatii "display" seteaza elementul ca tip bloc si afiseaza un punct in fata?
block list-item inline-block
.some_class {
  display: list-item;
}
Care instructiune JavaScript transforma un obiect in sir JSON.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicati clasa PHP folosita pentru a lucra cu elemente HTML si XML in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
Indicati forma de Prezent Continuu a verbului "to live" (a trai /a locui)
lived living liveing
I`m living here.
- Traiesc /Locuiesc aici.
Care este forma de Gerunziu (sau Participiu Prezent) a verbului "vivir" (a trai /a locui)?
vivió vivido viviendo
Estoy viviendo aquí.
- Traiesc /Locuiesc aici.
parseCSV

Last accessed pages

  1. PuzzleImg - Script creare Joc Puzzle din Imagine (1207)
  2. Cursuri Limba Germana (6325)
  3. Verbe neregulate (5275)
  4. Numere in JavaScript (2251)
  5. Coduri pt culori (69568)

Popular pages this month

  1. Cursuri si Tutoriale: Engleza, Spaniola, HTML, CSS, Php-Mysql, JavaScript, Ajax (687)
  2. Coduri pt culori (306)
  3. Exercitii engleza - English Tests and exercises - Grammar (303)
  4. Gramatica limbii engleze - Prezentare Generala (297)
  5. Cursuri limba engleza gratuite si lectii online (275)