Tema: Consejo :)
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/10/2007, 08:12
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 10 meses
Puntos: 292
Re: Consejo :)

Utiliza expresiones regulares siempre que puedas.........

EJ (hace otra cosa pero sirve)

Código PHP:
<?php
// parser de TAGS
// Example string
$str "Let's find the stuff <bla>in between</bla> these two previous brackets";

// Let's perform the regex
$do preg_match("/<bla>(.*)<\/bla>/"$str$matches);

// Check if regex was successful
if ($do true) {
    
// Matched something, show the matched string
    
echo htmlentities($matches['0']);

    
// Also how the text in between the tags
    
echo '<br />' $matches['1'];
} else {
    
// No Match
    
echo "Couldn't find a match";
}

?>
En tu caso el $do seria algo como ....

$do = preg_match("/<img(.*)>/", $str, $matches); // esto busca entre <img y >

Luego deberias buscar dentro de $matches el src=" " o bien buscar eso mismo de una.

preg_match_all busca no solo la primera coincidencia sino todas