{"id":103,"date":"2026-05-20T09:42:25","date_gmt":"2026-05-20T09:42:25","guid":{"rendered":"https:\/\/gigz.pk\/php\/?post_type=lesson&#038;p=103"},"modified":"2026-05-21T14:39:28","modified_gmt":"2026-05-21T14:39:28","slug":"array-functions","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/php\/?lesson=array-functions","title":{"rendered":"Array Functions"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Array functions are used to perform operations on arrays in programming and spreadsheet applications. Arrays store multiple values in a single variable, and array functions help manage, organize, search, filter, and manipulate that data efficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding array functions is important for developers, data analysts, and spreadsheet users because they simplify complex tasks and improve productivity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Objectives<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By the end of this training, you will be able to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Understand what arrays are<\/li>\n\n\n\n<li>Learn how array functions work<\/li>\n\n\n\n<li>Use common array functions effectively<\/li>\n\n\n\n<li>Organize and manipulate data efficiently<\/li>\n\n\n\n<li>Apply array functions in real-world projects<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What is an Array<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An array is a collection of multiple values stored in a single variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$colors = array(\"Red\", \"Blue\", \"Green\");<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the variable stores three different color values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importance of Array Functions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Array functions help users:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Store multiple values efficiently<\/li>\n\n\n\n<li>Reduce repetitive coding<\/li>\n\n\n\n<li>Process large datasets quickly<\/li>\n\n\n\n<li>Sort and organize information<\/li>\n\n\n\n<li>Search and filter data easily<\/li>\n\n\n\n<li>Improve application performance<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common Array Functions<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">array_push()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Adds one or more elements to the end of an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$fruits = array(\"Apple\", \"Banana\");<br>array_push($fruits, \"Orange\");<br><br>print_r($fruits);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Array ( &#91;0] =&gt; Apple &#91;1] =&gt; Banana &#91;2] =&gt; Orange )<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">array_pop()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Removes the last element from an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$numbers = array(10, 20, 30);<br><br>array_pop($numbers);<br><br>print_r($numbers);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">count()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the total number of elements in an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$students = array(\"Ali\", \"Ahmed\", \"Sara\");<br><br>echo count($students);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>3<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">array_merge()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Combines two or more arrays into one array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$array1 = array(\"Red\", \"Blue\");<br>$array2 = array(\"Green\", \"Yellow\");<br><br>$result = array_merge($array1, $array2);<br><br>print_r($result);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">in_array()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Checks whether a value exists inside an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$colors = array(\"Red\", \"Blue\", \"Green\");<br><br>if (in_array(\"Blue\", $colors)) {<br>    echo \"Color Found\";<br>}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">sort()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sorts an array in ascending order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$numbers = array(40, 10, 30, 20);<br><br>sort($numbers);<br><br>print_r($numbers);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">rsort()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sorts an array in descending order.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$numbers = array(40, 10, 30, 20);<br><br>rsort($numbers);<br><br>print_r($numbers);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">array_reverse()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Reverses the order of array elements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$letters = array(\"A\", \"B\", \"C\");<br><br>print_r(array_reverse($letters));<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">array_search()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Searches for a value and returns its index.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$fruits = array(\"Apple\", \"Banana\", \"Orange\");<br><br>echo array_search(\"Banana\", $fruits);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">explode()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Converts a string into an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$text = \"PHP,HTML,CSS\";<br><br>$result = explode(\",\", $text);<br><br>print_r($result);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">implode()<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Converts an array into a string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$colors = array(\"Red\", \"Blue\", \"Green\");<br><br>echo implode(\", \", $colors);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Red, Blue, Green<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Associative Arrays<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Associative arrays use named keys instead of numeric indexes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$student = array(<br>    \"name\" =&gt; \"Ali\",<br>    \"age\" =&gt; 20,<br>    \"city\" =&gt; \"Lahore\"<br>);<br><br>echo $student&#91;\"name\"];<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Multidimensional Arrays<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A multidimensional array contains one or more arrays inside another array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$students = array(<br>    array(\"Ali\", 20),<br>    array(\"Sara\", 22)<br>);<br><br>echo $students&#91;0]&#91;0];<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Real World Applications<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Array functions are commonly used in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Web development<\/li>\n\n\n\n<li>Database record handling<\/li>\n\n\n\n<li>E-commerce systems<\/li>\n\n\n\n<li>Student management systems<\/li>\n\n\n\n<li>Inventory management<\/li>\n\n\n\n<li>Data analysis projects<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use meaningful variable names<\/li>\n\n\n\n<li>Choose the correct array function for each task<\/li>\n\n\n\n<li>Keep arrays organized and readable<\/li>\n\n\n\n<li>Validate data before processing<\/li>\n\n\n\n<li>Avoid unnecessary loops when array functions can solve the task directly<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Advantages of Array Functions<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Faster data processing<\/li>\n\n\n\n<li>Cleaner code structure<\/li>\n\n\n\n<li>Easier data management<\/li>\n\n\n\n<li>Improved development efficiency<\/li>\n\n\n\n<li>Better handling of large datasets<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Final Presentation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In your final presentation, explain:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What arrays are<\/li>\n\n\n\n<li>Importance of array functions<\/li>\n\n\n\n<li>Commonly used array functions<\/li>\n\n\n\n<li>Examples of array manipulation<\/li>\n\n\n\n<li>Real-world applications of arrays<\/li>\n\n\n\n<li>Benefits of using array functions in programming<\/li>\n<\/ul>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/php\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Intermediate PHP > Arrays > Array Functions<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1779270136466\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":28,"template":"","class_list":["post-103","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Array Functions - Learn PHP with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/php\/?lesson=array-functions\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Array Functions - Learn PHP with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/php\/?lesson=array-functions\" \/>\n<meta property=\"og:site_name\" content=\"Learn PHP with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-21T14:39:28+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=array-functions\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=array-functions\",\"name\":\"Array Functions - Learn PHP with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\"},\"datePublished\":\"2026-05-20T09:42:25+00:00\",\"dateModified\":\"2026-05-21T14:39:28+00:00\",\"description\":\"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=array-functions#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=array-functions\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?lesson=array-functions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/php\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intermediate PHP > Arrays > Array Functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/php\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/php\\\/\",\"name\":\"Learn PHP with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/php\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Array Functions - Learn PHP with GiGz.PK","description":"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/php\/?lesson=array-functions","og_locale":"en_US","og_type":"article","og_title":"Array Functions - Learn PHP with GiGz.PK","og_description":"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.","og_url":"https:\/\/gigz.pk\/php\/?lesson=array-functions","og_site_name":"Learn PHP with GiGz.PK","article_modified_time":"2026-05-21T14:39:28+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/php\/?lesson=array-functions","url":"https:\/\/gigz.pk\/php\/?lesson=array-functions","name":"Array Functions - Learn PHP with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/php\/#website"},"datePublished":"2026-05-20T09:42:25+00:00","dateModified":"2026-05-21T14:39:28+00:00","description":"Learn PHP array functions with practical examples including sorting, searching, merging, and managing arrays easily.","breadcrumb":{"@id":"https:\/\/gigz.pk\/php\/?lesson=array-functions#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/php\/?lesson=array-functions"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/php\/?lesson=array-functions#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/php"},{"@type":"ListItem","position":2,"name":"Intermediate PHP > Arrays > Array Functions"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/php\/#website","url":"https:\/\/gigz.pk\/php\/","name":"Learn PHP with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/php\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/php\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}