Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
perso:quentin:php

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
perso:quentin:php [2019/09/30 18:20] – modification externe 127.0.0.1perso:quentin:php [2025/08/20 09:41] (current) – external edit 127.0.0.1
Line 69: Line 69:
 var_dump($app->getLogger()); var_dump($app->getLogger());
 </code> </code>
 +
 +=== Fonction sscanf ===
 +
 +[[https://www.php.net/manual/fr/function.sscanf.php]]
 +
 +> fonction pour "éclater" une chaîne 
 +
 +<code>
 +<?php
 +// Lecture d'un numéro de série
 +list($serial) = sscanf("SN/2350001", "SN/%d");
 +// et la date de fabrication
 +$mandate = "January 01 2000";
 +list($month, $day, $year) = sscanf($mandate, "%s %d %d");
 +echo "Le produit $serial a été fabriqué le : $year-" . substr($month, 0, 3) . "-$day\n";
 +
 +
 +// this function is a great way to get integer rgb values from the html equivalent hex.
 +list($r, $g, $b) = sscanf('00ccff', '%2x%2x%2x');
 +</code>
 +
 +
 +
perso/quentin/php.1569860433.txt.gz · Last modified: (external edit)