<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>function on Tutes Club</title><link>https://tutes.in/tag/function/</link><description>Recent content in function on Tutes Club</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 26 Nov 2026 20:29:06 +0000</lastBuildDate><atom:link href="https://tutes.in/tag/function/index.xml" rel="self" type="application/rss+xml"/><item><title>How to transpose an array in PHP with irregular subarray size?</title><link>https://tutes.in/how-to-transpose-an-array-in-php-with-irregular-subarray-size/</link><pubDate>Tue, 05 Mar 2019 14:04:04 +0000</pubDate><guid>https://tutes.in/how-to-transpose-an-array-in-php-with-irregular-subarray-size/</guid><description>&lt;p&gt;Transposing an array means turning its rows into columns: the first item of every sub-array becomes the first row, the second items become the second row, and so on. This is handy for CSV-style data where each sub-array is one column (a heading followed by its values) and the columns have different lengths, as in the test code below. A plain nested loop then leaves gaps in the shorter rows: a row can have keys &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;2&lt;/code&gt; but no &lt;code&gt;1&lt;/code&gt;, and something like &lt;code&gt;fputcsv()&lt;/code&gt;, which ignores keys, would shift the values into the wrong columns. This function fills those gaps with &lt;code&gt;null&lt;/code&gt;, so every row of the result has one slot per original sub-array.&lt;/p&gt;</description></item></channel></rss>