Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2013, 08:18
sulator
 
Fecha de Ingreso: septiembre-2013
Mensajes: 32
Antigüedad: 13 años
Puntos: 0
Pregunta Pasar variables PHP Javascript

Hola,

Quien puede ayudarme? Estoy intentando pasar este código php a javascript, soy novato en el tema java.

Gracias

Código PHP:
<?php


$link
[0] = array('link' => 'http://example.com/1', 'percent' => 25);
$link[1] = array('link' => 'http://example.com/2', 'percent' => 25);
$link[2] = array('link' => 'http://example.com/3', 'percent' => 25);
$link[3] = array('link' => 'http://example.com/4', 'percent' => 25);
$percent_arr = array();

foreach(
$link as $k => $_l) {
$percent_arr = array_merge($percent_arr, array_fill(0, $_l['percent'], $k));
}

$random_key = $percent_arr[mt_rand(0,count($percent_arr)-1)];

$redirectlink = $link[$random_key]['link'];

header("Location: $redirectlink");
?>