Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
PHP selecciona cadenas aleatorias de cadenas dadas

lo siento, soy nuevo en PHP. Me gustaría que mi código seleccione aleatoriamente entre estos: '/post371/', '/post375/', '/post377/',

pero cuando traté de acceder a mi URL, se redirige a https://example.com0 , https://example.com1 , https://example.com2 .

En lugar de, https://example.com/post371/ , https://example.com/post375/ , https://example.com/post377/

Aquí está mi código:

 <?php $pagez = array( '/post371/', '/post375/', '/post377/', ); if(empty($_GET['redir'])) { $_GET['redir'] = base64_encode(home_url() . array_rand($pagez)); } ?> <form id="landing" method="POST" action="<?php echo base64_decode($_GET['redir']); ?>"> <input type="hidden" name="newwpsafelink" value="<?php echo $_GET['code'] ?>"> </form> <script> window.onload = function() { document.getElementById('landing').submit(); } </script>

¡Gracias!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

array_rand devuelve una clave aleatoria de la matriz

Prueba esto: $_GET['redir'] = base64_encode(home_url() . $pagez[array_rand($pagez)])

over 4 years ago · Santiago Trujillo Report

0

La función array_rand devuelve una clave aleatoria de la matriz. Ya estás muy cerca, solo accede al elemento devuelto de esta manera:

 $_GET['redir'] = base64_encode(home_url() . $pagez[array_rand($pagez))];
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!