Skip to content

Instantly share code, notes, and snippets.

@4lb0
Created October 31, 2012 15:25
Show Gist options
  • Save 4lb0/3987656 to your computer and use it in GitHub Desktop.
Save 4lb0/3987656 to your computer and use it in GitHub Desktop.
Devuelve un listado de mensajes al azar (AJAX y jQuery - Curso Educacion IT)
<?php
$mensajes = array(
array('titulo' => 'Notificacion 1', 'mensaje' => 'Mensaje ejemplo'),
array('titulo' => 'Hola Mudo', 'mensaje' => 'como estas?'),
array('titulo' => 'Puto el que lee', 'mensaje' => 'Leiste ja!'),
array('titulo' => 'Ganaste', 'mensaje' => 'Un verdadero premio'),
array('titulo' => 'Sos el visitante numero 1000', 'mensaje' => 'No ganaste nada'),
);
shuffle($mensajes);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array_slice($mensajes, mt_rand(0, count($mensajes))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment