website logo
Auteur
avatar
oim

Forum » » Le coin des codeurs » » [Résolu] - image


Posté : 27 sept. 2004 à 10:37 icone du post

Comme ca c pas bon, c quoi qui ne vas pas ?


<?PHP
if(!isset($mainfile)) { !include!("mainfile.php"); }
global $pdst; $pdst=
"1";

   !include!(
"header.php");

function img_extractor_string($chaine)
{ 
$retour = array();
  while($x = stristr($chaine, 
"<img")){ 
  $image = substr($x, 4, strpos($x, 
">")-4);
  #print 
"n";
  $chaine = substr($x, strpos($x, 
">"));

  preg_match_all(
"/b([^s]+)s*=s*("|')(.*?)("|')s/"" $image ", $attribut);
  $details = arrays2hash($attribut
[1], $attribut[3]);
  $details
['tag'] = $image;

  $image2 = preg_replace(
"/b([^s]+)s*=s*("|')([s]*?)("|')s/"""" $image ");
  preg_match_all(
"/b([^s]+)s*=s*([^s]*?)s/"" $image2 ", $attribut);
  // l'ordre du merge est important : on ecrase les valeurs 
trouvees sans guillemets 
  // par celle trouvee avec.
  $details = array_merge( arrays2hash($attribut
[1], $attribut[2]), $details);
  array_push($retour, $details);
  
} 
  return $retour;
}

   OpenTable();
   echo 
"<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
    $result=mysql_query(
"select content from seccont where secid='10' ");
    list($content) = mysql_fetch_row($result);
    $imgs = img_extractor_string($content)
         echo 
"<tr><TD CLASS=\"HEADER\">print_r($imgs);</td></tr>";

     
   echo 
"</TD></TR></TABLE>\n";
   CloseTable();
   !include!(
"footer.php");

?>



Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=12098&forum=5