Thanks John,
Unfortunately this throws up the following error.
syntax error, unexpected 'foreach' (T_FOREACH)
I tried adding a ); to the line above the foreach but then the value errored
syntax error, unexpected ''.$value.'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'