views:

28

answers:

3

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?

+1  A: 
<?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.

fcingolani
+1  A: 

How about:

$on_going = FALSE;
$statuses = '';

foreach(...)
{
    if($status == 'on_going') { $on_going = TRUE; }
    $statuses .= $status;
}
captaintokyo
A: 
foreach($array as $status) [
  $$status = 1; // creates a variable for each array element.
}
codaddict