Foros del Web » Programando para Internet » PHP »

ayuda con funcion

Estas en el tema de ayuda con funcion en el foro de PHP en Foros del Web. <table width="100%" border="0"> <tr> <td width="59%"><p><big> <br> <font face=Arial size=2><strong><a title=" te regalo amores (rMx) - rakin y ken-y feat ivy queen " href="listen.php?v= e56950e ...
  #1 (permalink)  
Antiguo 14/03/2009, 13:25
 
Fecha de Ingreso: marzo-2009
Mensajes: 6
Antigüedad: 15 años, 1 mes
Puntos: 0
Pregunta ayuda con funcion

<table width="100%" border="0">
<tr>
<td width="59%"><p><big>
<br> <font face=Arial size=2><strong><a title="te regalo amores (rMx) - rakin y ken-y feat ivy queen" href="listen.php?v=e56950e" class="escuchar"><font face=Verdana size=2><strong> te regalo amores (rMx) - (rakin y ken-y feat ivy queen)</strong></font></a></strong> <a class="normal" href="listenwin.php?v=e56950e" target="_blank" onClick="window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=no,m enubar=no,scrollbars=no,resizable=no,width=710,hei ght=265'); return false;"></a><br>
<br><img src="files/listen.gif" title="Listen" alt="Listen" /><strong><a title="Presiento - rakin y ken-y" href="listen.php?v=2f4b509" class="escuchar"><font face=Verdana size=2><strong> Presiento - (rakin y ken-y)</strong></font></a></strong> <a class="normal" href="listenwin.php?v=2f4b509" target="_blank" onClick="window.open(this.href, this.target, 'toolbar=no,location=no,directories=no,status=no,m enubar=no,scrollbars=no,resizable=no,width=710,hei ght=265'); return false;"><img border="0" src="files/newwindow.gif" title="Open in new window" alt="Open in new window"><font face=Verdana size=1>Small window</font></a><br><br><img src="files/listen.gif" title="Listen" alt="Listen" /><strong><a title="no tengo nada (paRiS) - rakin y ken-y" href="listen.php?v=844a8d9" class="escuchar">
...

de todo esas lineas de html solo deseo sacar lo q esta en rojo quiero

con esta funcion preg_match_all
yo hice asi pero no me funciona bien

$texto = '...';

echo preg_match_all("/\"(.*)\" href=\"listen.php\?v=([a-z0-9]+)\"\ class=\"escuchar\">/i", $texto, $matches);
echo '<pre>'.print_r($matches, true).'</pre>';

resultado + ó - asi
Array(
[0] => Array (
[0] => "Presiento1 - rakin y ken" href="listen.php?v=1c3b5f2" class="escuchar">
[1] => "Presiento2 - rakin y ken" href="listen.php?v=1e3b5hd" class="escuchar">
[2] => "Presiento3 - rakin y ken" href="listen.php?v=1f3b5rv" class="escuchar">
[3] => "Presiento4 - rakin y ken" href="listen.php?v=1d3b5s3" class="escuchar"> )

[1] => Array (
[0] => Presiento1 - rakin y ken
[1] => Presiento2 - rakin y ken
[2] => Presiento3 - rakin y ken
[3] => Presiento4 - rakin y ken )
[2] => Array (
[0] => 1c3b5f2
[1] => 1e3b5hd
[2] => 1f3b5rv
[3] => 1d3b5s3
)
)


por favor necesito su ayuda :(

Última edición por dozarli; 14/03/2009 a las 13:28 Razón: FR
  #2 (permalink)  
Antiguo 14/03/2009, 15:34
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con funcion

Solo agrega en el patron, que toma lo que esta en las etiquetas <a>, los valores que quieres. El title y la variable v del link.

En la seccion de aportes hay un manual sobre expresiones PCRE.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:32.