-1

如何将输出/派生值分配给 FOR LOOP 内的数组

$num = count($email);
  for($i=0; $i < $num; $i++){
      $result = do_post_request("http://api.mysite/api/IsActiveAccount?email=". $email[$i], null);
      $status = str_replace('{"result":', "", $result);
      $status = str_replace('}', "", $status);
      echo  $email[$i] ;
   }

OUTPUT---->
  red@yahoo.com
  blue@yahoo.com
  yellow@yahoo.com
  white@yahoo.com

如何在数组中分配/放置它?像这个。

  $value = array("red@yahoo.com","blue@yahoo.com","yellow@yahoo.com", "white@yahoo.com")
4

3 回答 3

2

尝试分配$email[$i]$value喜欢

for($i=0; $i < $num; $i++){
  $result = do_post_request("http://api.mysite/api/IsActiveAccount?email=". $email[$i], null);
  $status = str_replace('{"result":', "", $result);
  $status = str_replace('}', "", $status);
  $value[] = $email[$i] ;    // Here it will assign $email in $value as an array 
}
print_r($value);
于 2013-09-03T12:23:08.980 回答
0
$value = array();

for($i=0; $i < $num; $i++){

 $result = do_post_request("http://api.mysite/api/IsActiveAccount?email=". $email[$i], null);
$status = str_replace('{"result":', "", $result);
$status = str_replace('}', "", $status);
$value[] = $email[$i] ;

}

print_r($value);
于 2013-09-03T12:27:50.790 回答
0

不是 JSON 吗?

 $values = array();
 for($i=0; $i < $num; $i++){
    $result = do_post_request("http://api.mysite/api/IsActiveAccount?email=". $email[$i], null);
    $result = json_decode($result);
    $values[] = $result['result'];
 }
于 2013-09-03T12:29:23.737 回答