There's no need to escape double quotes within single quotes.
<?php echo ($i % 6 == 5) ? 'style="margin-right:0px"' : ''; ?>
You only need to escape single quotes within single quotes or double quotes within double quotes. If you want to write a single quote within a single quoted string, that single quote would terminate the string.
$foo = 'a'b';
PHP sees this as the string a, followed by a meaningless b and the start of the string '; which is never terminated; which is invalid syntax.
$foo = 'a\'b';
This is correctly parsed as the string a'b. You have escaped the meaning the quote would usually have at this point.
With double quotes within single quotes, there's no such ambiguity. A double quote within a single quoted string does not terminate the string, it has no such special meaning there that would need escaping. If you include a backslash, the backslash is used literally.
$foo = 'a"b'; // a"b
$foo = 'a\"b'; // a\"b
I suppose the problem is how you look at the output. If the output is style=\"…\", the escaped double quotes might cause invalid syntax in the environment where you're looking at the output.