tags:

views:

34

answers:

2

Hello Guys, I have a little newbie's hitch.

I have got something like this:

// Assign Device ID
if ($line == "IMEI 358998018395510\r\n"){
 $device_id = 1;
 }elseif($line == "IMEI 352924028650492\r\n"){
 $device_id2 = 3;
}
 ........
 ........
 if (fwrite($outFile,$device_id or device_id2. ",". $date.",".$line)===FALSE){

I want to be able to determine which one of the variables of device_id or device_id 2 would finally be the result so i can append it to the fwrite statement on the last line above. Can someone please show how? Thanks.

+2  A: 

You just have to use the same variable:

// Assign Device ID 
if ($line == "IMEI 358998018395510\r\n"){ 
 $device_id = 1; 
 }elseif($line == "IMEI 352924028650492\r\n"){ 
 $device_id = 3; 
} 
 ........ 
 ........ 
 if (fwrite($outFile,$device_id . ",". $date.",".$line)===FALSE){ 
klausbyskov
thanks Kalusbyskov
ibiangalex
A: 

This?

// Assign Device ID
if ($line == "IMEI 358998018395510\r\n"){
 $device_id = 1;
 }elseif($line == "IMEI 352924028650492\r\n"){
 $device_id = 3;
}
 ........
 ........
 if (fwrite($outFile, $device_id . "," . $date . "," . $line)===FALSE){

Or

$resultId = $device_id == null : $device_id2 ? $device_id;
if (fwrite($outFile, $resultId . "," . $date . "," . $line)===FALSE){
Mark Baijens
Many thanks. That is interesting. I would try that out.
ibiangalex