How to set PCF8574 using 8 variables

Build up the variables into the byte to send using the bitwise OR and shifts If you variables only contain 0 or 1 you can use:-

byteToSend = P1 | (P2 <<1) | (P3 << 2) | (P4 << 3) ....... and so on