{"id":62,"date":"2023-05-06T02:58:10","date_gmt":"2023-05-06T02:58:10","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=62"},"modified":"2023-05-06T02:58:10","modified_gmt":"2023-05-06T02:58:10","slug":"what-are-the-array-functions-in-php-explain-with-an-example","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/06\/what-are-the-array-functions-in-php-explain-with-an-example\/","title":{"rendered":"What are the array functions in PHP explain with an example."},"content":{"rendered":"\n<p>PHP provides various array functions to access and manipulate the elements of the array. The important PHP array functions are given below.<\/p>\n\n\n\n<p><strong>array() function<\/strong><\/p>\n\n\n\n<p>PHP array() function creates and returns an array. It allows you to create indexed, associative and multidimensional arrays.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>array array ([ mixed $&#8230; ] )<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$season=array(&#8220;summer&#8221;,&#8221;winter&#8221;,&#8221;spring&#8221;,&#8221;autumn&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo &#8220;Season are: $season[0], $season[1], $season[2] and $season[3]&#8221;;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>Season are: summer, winter, spring and autumn<\/p>\n\n\n\n<p><strong>array_change_key_case() function<\/strong><\/p>\n\n\n\n<p>The PHP array_change_key_case() function changes the case of all keys of an array.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>array array_change_key_case ( array $array [, int $case = CASE_LOWER ] )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$salary=array(&#8220;Sonoo&#8221;=&gt;&#8221;550000&#8243;,&#8221;Vimal&#8221;=&gt;&#8221;250000&#8243;,&#8221;Ratan&#8221;=&gt;&#8221;200000&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>print_r(array_change_key_case($salary,CASE_UPPER));&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Array ( [SONOO] =&gt; 550000 [VIMAL] =&gt; 250000 [RATAN] =&gt; 200000 )<\/p>\n\n\n\n<p><strong>array_chunk() function<\/strong><\/p>\n\n\n\n<p>PHP array_chunk() function splits arrays into chunks. By using array_chunk() method, you can divide the array into many parts.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>array array_chunk ( array $array , int $size [, bool $preserve_keys = false ] )&nbsp;&nbsp;<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$salary=array(&#8220;Sonoo&#8221;=&gt;&#8221;550000&#8243;,&#8221;Vimal&#8221;=&gt;&#8221;250000&#8243;,&#8221;Ratan&#8221;=&gt;&#8221;200000&#8221;);&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>print_r(array_chunk($salary,2));&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>Array (&nbsp;<\/p>\n\n\n\n<p>[0] =&gt; Array ( [0] =&gt; 550000 [1] =&gt; 250000 )&nbsp;<\/p>\n\n\n\n<p>[1] =&gt; Array ( [0] =&gt; 200000 )<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP provides various array functions to access and manipulate the elements of the array. The&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/62"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/62\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}