Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Exploding array and adding execution timestamp for each bit of data in the array? -


using curl_multi, have loaded 3 url's , printed array.

1) how can set timestamp on output let me know when each url run?

2) how can explode array display data , timestamp, excluding text "array ( [0] =>", "[1] =>", "[2] =>" , " )"?

code

<?php  function multirequest($data, $options = array()) {    // array of curl handles   $curly = array();   // data returned   $result = array();    // multi handle   $mh = curl_multi_init();    // loop through $data , create curl handles   // add them multi-handle   foreach ($data $id => $d) {      $curly[$id] = curl_init();      $url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;     curl_setopt($curly[$id], curlopt_url,            $url);     curl_setopt($curly[$id], curlopt_header,         0);     curl_setopt($curly[$id], curlopt_returntransfer, 1);      // post?     if (is_array($d)) {       if (!empty($d['post'])) {         curl_setopt($curly[$id], curlopt_post,       1);         curl_setopt($curly[$id], curlopt_postfields, $d['post']);       }     }      // options?     if (!empty($options)) {       curl_setopt_array($curly[$id], $options);     }      curl_multi_add_handle($mh, $curly[$id]);   }    // execute handles   $running = null;   {     curl_multi_exec($mh, $running);   } while($running > 0);    // content , remove handles   foreach($curly $id => $c) {     $result[$id] = curl_multi_getcontent($c);     curl_multi_remove_handle($mh, $c);   }    // done   curl_multi_close($mh);    return $result; }    $data = array(array(),array());  $data[0]['url']  = 'http://search.yahooapis.com/videosearchservice/v1/videosearch?appid=yahoodemo&query=pearl+jam&output=json'; $data[1]['url']  = 'http://search.yahooapis.com/videosearchservice/v1/videosearch?appid=yahoodemo&query=black+eyed+peas&output=json'; $data[2]['url']  = 'http://search.yahooapis.com/videosearchservice/v1/videosearch?appid=yahoodemo&query=nirvana&output=json';  $r = multirequest($data);  print_r($r);  ?> 

output

array ( [0] => pearl jam <br>         [1] => black eyed peas<br>         [2] => nirvana )  

preferred output

01:00:01 pearl jam <br> 01:00:02 black eyed peas<br> 01:00:03 nirvana  

i'd keep simple...just loop set timestamp , single curl call, explode resultarray , filter out key or values don't need.

for curl call:

$r= array();  foreach($urls $url) {  $r[]["timestamp"]= time();  $output= curl_exec($url);  $r[]["bandname"]= $output; } 

your final loop like

foreach($r $key=>$value){  print $value["timestamp"];  print $value["bandname"];  print "<br>"; } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -