@Jony1337

Проблемы с массивом в php?

Есть массив
<?php

  $quotes[] = 'text1';
    $quotes[] = 'text2';
    $quotes[] = 'text3';
    $quotes[] = 'text4';
    $quotes[] = 'text5';
 srand ((double) microtime() * 1000000);
    $rs = rand(0,count($quotes)-1);


когда я хочу вывести $r мне должно выводить радномно от text1 до text5 но мне выводить или 0 или 1 или 2 а не нужный мне текст
вот код вывода
<?php
$html = <<<HERE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>$pagina</title>
<meta property="og:title" content="  $rs   " /> 
<meta property="og:description" name="description" content="$descriere">
<meta property="og:type" content="photo" />
<meta property="og:image" content="http://site.ru/images/$userin.png" />
<script type="text/javascript">  
  location.replace("http://site.ru/start.php");  
  </script>
</head>
<body>
</body>
HERE;
?>
  • Вопрос задан
  • 138 просмотров
Решения вопроса 1
DevMan
@DevMan
вы же выводите свое рандомное число, а не элемент массива
<meta property="og:title" content="  $quotes[ $rs ]   " />
или
$rs = $quotes[ rand(0,count($quotes)-1) ];
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы