⊗ppPmMdAr 135 of 447 menu

Arbitrary Arrays in PHP

Multidimensional arrays do not necessarily have to be like the ones we considered above. Take a look, for example, at the following array:

<?php $arr = [['a', 'b', [1, 2, 3], [4, 5]], ['d', ['e', 'f']]]; ?>

If we rewrite it in a more understandable form, we will see that this array is "irregular". In it, arrays are located next to ordinary elements:

<?php $arr = [ [ 'a', 'b', [1, 2, 3], [4, 5], ], [ 'd', ['e', 'f'], ], ]; ?>

Given the following array:

<?php $arr = [[1, 2, 3, [4, 5, [6, 7]]], [8, [9, 10]]]; ?>

Find the sum of all elements of the given array. Access each element individually, without a loop.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline