2

This question is an exact duplicate of:

I tried to post this exact answer on Stack Overflow, however it refuses to let me do so.

I tried searching around a bit, and found some people suggesting adding extra line breaks before code blocks. This didn't work.

You need to create a loop that goes through each possible value. Often, you'd just use a for loop.

for($i = 0; $i < count($cars); $i++) {
    if($cars[$i]['brand'] == "BMW")
        echo $cars[$i]['color'];
}

However, using a foreach loop is also an option, and it looks neater.

foreach($cars as $v) {
    if($v['brand'] == "BMW")
        echo $v['color'];
}

See the array, for loop and foreach loop documentation for more information

(link)
(link)
(link)

(Note that the (link)s down the bottom are links on Stack Overflow using the [text](link) method; I just couldn't post them here because of having under 10 reputation.)

I have almost no doubt that this is happening because I've done something wrong, but for the life of me I can't spot what it is.

Edit: Updates based on questions in the comments
I receive this message exactly in a red box to the side of my answer:

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

I'm on Chrome version 34.0.1847.116 m, Windows 7 64-bit.

Edit 2: As per Mat's suggestion, I tried putting all the links in an unordered list, with one blank line between them. This worked perfectly and the message was submitted.

I believe this question should remain as a bug report, as this sounds like a bug to me.

marked as duplicate by Gilles, hims056, Azik, Shog9 Apr 27 '14 at 19:07

This question was marked as an exact duplicate of an existing question.

  • 1
    Looks fine. Did the preview look ok? Try putting the links in a list (make sure there's a blank line before them, then put each link on a separate line that starts with a * and a space) – Mat Apr 25 '14 at 9:01
  • On which browser and OS are you? – rene Apr 25 '14 at 9:28
  • 2
    Since the quality filters apply to all sites, I don't see how this is off-topic here. – Martijn Pieters Apr 25 '14 at 9:37
  • What exact message you get when trying to post this? – ShaWiz Apr 25 '14 at 11:18
  • I receive this message exactly in a red box to the side of my answer: "Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon". This is a screenshot of the preview: puu.sh/8mL6g/df397501d3.png. I'm on Chrome version 34.0.1847.116 m, Windows 7 64-bit. And, all of this has been added to the main question since it's easier to read there. – Nerixel Apr 25 '14 at 11:47
  • @Mat Putting the links in an unordered list seemed to work. Surely this is a bug, it can't be intentional that three links be considered misformatted code? – Nerixel Apr 25 '14 at 11:52
  • @MartijnPieters There is a quality filter on all sites, but not code detection heuristics, which would be irrelevant on most sites. I think only SO has the code detection heuristics. – Gilles Apr 25 '14 at 11:53
  • @Gilles: fair enough and that does make sense; do we have a post somewhere here on MSE to confirm this? – Martijn Pieters Apr 25 '14 at 11:58
  • @AgentTadpole: borderline. Agreed three markdown-formatted links in a row doesn't look like code, but it certainly doesn't look like English text either. (BTW: you don't need a blank line in between each element in the list, just one before (and one after). If you remove the blank, the list will be more compact.) – Mat Apr 25 '14 at 12:03
  • @Mat thanks for your help. If anything, three links in a row should be detected as spam, not misformatted code (at least in my opinion). – Nerixel Apr 25 '14 at 12:07
  • This is not a SO-specific problem, although most of you can be forgiven for not knowing which sites this check is enabled on. If it had been asked on MSO, that would've been fine, but posting bug reports here is good too. – Shog9 Apr 27 '14 at 19:06