Use an expression to select an array value in PHP. It's handy for quick output logic. Update: it's a bit too clever, perhaps, versus using the tenary operator.

$classes .= [ ' sort-default', ' sort-custom' ][ has_custom_sort( $post ) ];

#php #technology #tips

January 31 at 11:57 am

Related posts

  • January 31 at 11:57 am Use an expression to select an array value…
  • January 2 at 9:59 am PHP-Activate 0.3.1…
  • December 15 at 9:47 am PHP-Activate 0.3.0…
  • October 5 at 8:59 am PHP-Activate 0.2.0…
  • March 21, 2023 at 2:28 pm I've released php-activate 0.1.2, a PHP pr…
  • March 21, 2023 at 12:41 pm Basic routing using REQUEST_URI…
  • February 21 at 11:07 am Navigate Xbox Series console using LG remo…
  • February 12 at 10:38 am Looking at my browser tabs, I can't believ…
  • January 31 at 2:30 pm Content vs crap. #technology…
  • January 23 at 11:21 am Why do web-browsers not have a dedicated &…
  • January 16 at 4:33 pm Finally updated my #WordPress Blocks In Pl…
  • January 3 at 2:07 pm What would it take to make writing vanilla…
  • January 2 at 4:37 pm If you're using the Anytype (current versi…
  • December 11 at 8:51 am I experimented with _hyperscript to replac…
  • November 14 at 10:08 am Ashley Belanger writes for Ars Technica Ap…
  • September 22 at 9:12 am On personal goals…
  • September 9 at 12:56 pm If you want an example of why we need a vi…
  • August 3 at 9:03 am Anchor bugs in Blink engine browsers…
  • April 10, 2023 at 10:41 am The AI evolution seems scary until you rea…
  • April 6, 2023 at 10:43 am Ubuntu's minimal installation appears to b…
  • March 24, 2023 at 7:24 am Anyone, regardless of coding experience ca…