How can I write this if condition in switch method?
if( $k != \'pg_id\' && $k != \'pg_tag\' && $k != \'pg_user\' )
{
Use break to prevent follow through to next case:
switch($k)
{
case 'pg_id':
case 'pg_tag':
case 'pg_user':
// any match triggers this block; break causes no-op
break;
default:
$result = $connection->run_query($sql,array(...));
}
I'm not sure why you want to use a switch statement for this though.
If it's for readability, you could try this instead:
if($k != 'pg_id' &&
$k != 'pg_tag' &&
$k != 'pg_user')
{
$result = $connection->run_query($sql,array(...));
}