{
  "id": 8662841,
  "title": "A real world case of recursion done right in PHP",
  "url": "https://urgent.news/2026/09/20/a-real-world-case-of-recursion-done-right-in-php",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-20T09:51:49.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tiaya/a-real-world-case-of-recursion-done-right-in-php-428k"
  },
  "original_language": "en",
  "account": "Nick Cosentino shared a real-world example of recursion on Twitter in October 2025, receiving significant engagement. He argues that recursion can be simpler than its iterative counterpart in certain cases. To illustrate this, he uses the Fibonacci sequence as an example.\n\nThe recursive algorithm for the Fibonacci sequence is defined as follows:\n- If n = 0 or n = 1, fib(n) = 1\n- Otherwise, fib(n) = fib(n - 1) + fib(n - 2)\n\nThis recursive definition can be implemented without loops or intermediate variables, showcasing the power of recursion in such scenarios.\n\nThe PHP UI Builder library, used for building application UIs, is particularly well-suited for recursive algorithms due to its hierarchical component structure. Components can have properties, contain other components, and be either real or virtual. The library introduces virtual components such as When, Each, Pick, and List to handle various data processing scenarios.\n\nFor example, the When component takes a condition and generates a component if the condition is met. The Each component generates a component for each element in an array of data. The Pick component generates a different component based on the first true condition from a list of conditions. The List component aggregates a set of components into one.\n\nBy using a recursive approach, the UI Builder can efficiently handle complex hierarchical structures, making it well-suited for building dynamic and interactive user interfaces.",
  "summary": "Nick Cosentino @DevLeaderCa posted this message about recursion on X, ex Twitter, in October 2025, which received over 460 replies. // Detect dark theme var iframe = document.getElementById('tweet-1984123215170421060-448'); if (document.body.className.includes('dark-theme')) { iframe.src = \"https://platform.twitter.com/embed/Tweet.html?id=1984123215170421060&theme=dark\" } I quote an excerpt: I've…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}