Wedding wardrobe malfunctions: From creases to bad fits, the famous brides whose gowns let them down - as fans spot a flaw in Dua Lipa's skirt suit
Best fitness tracker: We put six of the best to the test monitoring our workouts, sleep and hormones over several weeks
Reform winning next election growing more likely, UK's leading pollster says, as party's backers driven by 'distinct socially Conservative' ideology and not just 'protest' voters
Kendall Jenner and Jacob Elordi look closer than ever as hot new couple cozy up at intimate dinner in Tokyo
Kim Kardashian enjoys a romantic bike ride with boyfriend Lewis Hamilton before delighting the F1 star with bikini-clad snaps as their 'intense' romance heats up
Motorcyclist killed in M11 crash which shut motorway for hours
Details of Trump's expletive-laden phone call with Netanyahu revealed as President pushes to broker peace deal
I met Martine Vik Magnussen's father and learned the heartbreaking truth about her killer's escape from justice and Epstein's links behind the tragedy
'Who can we tax so we can pay more benefits?': What Starmer's former aide said was discussed at every Labour meeting
Labour's poisonous puppet master and a £1million cover-up: The 1,500 new pages are a sea of Tipp-Ex. But they still expose malign back-biting of a peer for whom Starmer sabotaged his own career by making him US ambassador
Texas Adds Another Huge Solar Farm As ERCOT Grid Demand Soars
Read more of this story at Slashdot.
Southend bar and coffee lounge 'devastated' as it announces 'immediate' closure
'You legend. Manager loved it!': Southampton's spying WhatsApp message leaked after they were thrown out of play-off final - revealing 'extreme pressure' put on interns... as club decide on Tonda Eckert's future
Arsenal fan from Essex who vowed not to cut beard until team wins league finally shaves
Static caravans burn down in huge fire in Burnham
Essex friends fly to Lake Garda and the whole trip was just £120
Police release bodycam footage of murdered Essex student in final moments
Police release bodycam footage of murdered Essex student in final moments
CodeSOD: Blocked the Date
Volodya sends us some bad date handling code in PHP. Which, I know, you're just reaching for the close tab and yawning when you hear that. You've seen it before. But bear with me, this one still has some fun bits to it.
$monthes = array( 1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря' );This creates a list of months.
if ( $team->have_posts() ) : // Start the Loop. while ( $team->have_posts() ) : $team->the_post();Today, I have learned something about PHP. PHP has an alternate syntax for blocks. Instead of if { statements }, you can do: if : statements endif. Just one more quirk of PHP to make the language more confusing.
This block checks have_posts in an if, and then checks it again in a while, meaning we don't need the if at all, but so it goes. We haven't gotten to the date handling yet, so let's look at that.
$date = get_the_date(); $d1 = explode(".", $date); if ($d1[1][0]=='0') $m = $d1[1][1]; else $m = $d1[1][0]; ?><div class="date"><?php echo $d1[0]." ".$monthes[$m]." ".$d1[2]; ?></div>We get the date as a string, and then split it out into date parts. This is, of course, highly locale specific, but clearly they know what locale they're in. Then they look at the array of date parts. The second element holds their "month" string, as two digits, so they look at the digits. If the month string starts with a 0, they grab the second character and put it in $m. Otherwise, they grab the first character and put it in $m. Then they use $m to look up the $monthes.
Unless there's some substring weirdness going on that I don't know about, this code… doesn't work? Right? Since they're grabbing only a single character out of $d1[1] every time, for months later in the year, $m is only ever going to hold 1, and thus we only output Января, meaning we get four months of January, which just seems cruel, honestly, at least in the Northern Hemisphere.
As with all bad date handling code, this could easily be fixed by just using the built in functions, even in PHP. What I'm going to take away from this though is that PHP's syntax lets you write in Visual Basic or Ruby if you're determined enough. And you can mix and match, so enjoy a codebase that has :/endif and {} scattered throughout.
.comment { border: none; } [Advertisement] Plan Your .NET 9 Migration with ConfidenceYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!