Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Поиск и замена
Форумы портала PHP.SU » » Хранение данных, их вывод и обработка » Поиск и замена

Страниц (1): [1]
 

1. CRAZySTR - 27 Августа, 2014 - 07:44:50 - перейти к сообщению
нужна помощь, не могу понять что и как
к примеру имеется текст

Спойлер (Отобразить)


в этом тексте есть id и имя участника

текст поделил данным примером
PHP:
скопировать код в буфер обмена
  1. $text = str_replace("|"," ",$text);
  2.         $text = str_replace("[","",$text);
  3.         $text = str_replace("]","",$text);
  4. $result = explode(" ", $text);

а в тексте что выше таких участников много. Как считать и выводить результат ?

PHP:
скопировать код в буфер обмена
  1. $message = "";
  2. $msg = json_decode(file_get_contents("http://api.vk.com/method/wall.get?domain=vkdesigners&count=1"), false);
  3. for($i = 1; $i < 2; $i++) {
  4.         if(isset($msg->response[$i]->text)) $link = $msg->response[$i]->text;
  5.         if(isset($msg->response[$i]->from_id)) $wall = $msg->response[$i]->from_id;
  6.         if(isset($msg->response[$i]->id)) $wall1 = $msg->response[$i]->id;
  7.         if(isset($msg->response[$i]->date)) $wall2 = $msg->response[$i]->date;
  8.         if(isset($msg->response[$i]->reposts->count)) $repost = $msg->response[$i]->reposts->count;
  9.         if(isset($msg->response[$i]->likes->count)) $like = $msg->response[$i]->likes->count;
  10.        
  11. $text = preg_replace("/(^|[\n ])([\w]*?)((ht)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" target=\"_blank\">$3</a>", $link);
  12.        
  13.         $text = str_replace("|"," ",$text);
  14.         $text = str_replace("[","",$text);
  15.         $text = str_replace("]","",$text);
  16.         $result = explode(" ", $text);
  17.  
  18.         $date = user::times( $wall2 );
  19.         $message .= "<div class=\"media\">
  20.                        <div class=\"media-body\">
  21.                            {$text}
  22.                            <div class=\"clearfix\"></div>
  23.                            <div class=\"attrs\">Дата публикации: {$date}</div>
  24.                            <div class=\"block attrs\">Like: {$like}</div>
  25.                            <div class=\"block attrs\">Repost: {$repost}</div>
  26.                                                         <div class=\"list-options\">
  27.                                                                 <a href=\"http://vk.com/wall{$wall}_{$wall1}\" target=\"_blank\" class=\"btn btn-sm\">Показать полностью</a>
  28.                                                         </div>
  29.                        </div>
  30.                    </div>";
  31. }

P.S сам сделал

 

Powered by ExBB FM 1.0 RC1