Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/09/2011, 10:38
Tunnecino
 
Fecha de Ingreso: julio-2011
Mensajes: 22
Antigüedad: 12 años, 10 meses
Puntos: 2
Respuesta: Sistema de Quotes #Post

Por ahora he conseguido separar todos los #numero, de esta forma:

Código:
$array3 = explode(" ", $string);

foreach($array3 as $bucle) {
	$bucle2 = explode("#", $bucle);
	foreach($bucle2 as $bucle3) {
		if (is_numeric($bucle3)) {
			$bucle4[] .= $bucle3;
		}
	}
}

foreach($bucle4 as $bucle5) {
	# Buscamos el post del quote
	ConexionDB();
	# Get Relacionadas
	$query = mysql_query('SELECT mensaje FROM noticias_comentarios WHERE idn = "'.$idn.'" AND idp = "'.$bucle5.'"');
	$check = mysql_num_rows($query);
	if($check == 0) {
		$cadena = '<a class="tooltip" href="#'.$bucle5.'" ref="El mensaje #'.$bucle5.' no existe"><strong>#'.$bucle5.'</strong></a>';
	}else{
		$fetch = mysql_fetch_array($query);
		$cadena = '<a class="tooltip" href="#'.$bucle5.'" ref="'.$fetch['mensaje'].'"><strong>#'.$bucle5.'</strong></a>';
	}
	# Volvemos a buscar el #
	$find = array('#'.$bucle5);
	$replace = array($cadena);
	$string = str_replace($find, $replace, $string);
}
Pero a la hora de hacer str_replace, si hay 2 y 25, el 25 no me lo cambia, solo el 25.