How can I store the status in an array after concatenating
Example: (if the status can be: 'done', on_going', 'to_verify')
for loop starts here --------
I used
$status .= $status;
and if I perform
echo $status;
it will give me 'doneon_goingdoneto_verify'
for loop endshere --------
I would want to perform something based on the status like if there's 'on_going' status then set
开发者_运维技巧$on_going =1;
However, if I performed concat, I can't check status by status. Any suggestion how I can do this?
<?php
$statuses = array();
foreach($foo as $bar){
$statuses[] = $bar;
}
if(in_array('on_going', $statuses)){
echo "It's on going!";
}
?>
This will allow you to have simultaneous statuses, like "on going" and "delayed" at the same time.
How about:
$on_going = FALSE;
$statuses = '';
foreach(...)
{
if($status == 'on_going') { $on_going = TRUE; }
$statuses .= $status;
}
foreach($array as $status) [
$$status = 1; // creates a variable for each array element.
}
精彩评论