# array_filter in php

<div class="WaaZC" id="bkmrk-the%C2%A0array_filter%28%29%C2%A0f" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="rPeykc" data-hveid="CCIQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegQIIhAB" style="margin: 0px 0px 10px;"><span data-huuid="1377138552053823047">The `array_filter()` function in PHP is used to filter elements of an array based on a callback function. </span><span data-huuid="1377138552053825308">It iterates over each value in the input array, passes it to the callback function, and includes the element in the result array if the callback function returns `true`.<span class="pjBG2e" data-cid="7e79bc24-e43b-42d7-87f2-303c5f4ce524"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="7e79bc24-e43b-42d7-87f2-303c5f4ce524" data-uuids="1377138552053823047,1377138552053825308" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CB8QAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ3fYKegQIHxAB" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-flex !important; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(229, 237, 255) !important; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div></div></div><div class="WaaZC" id="bkmrk-syntax%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBsQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegQIGxAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="1377138552053821638">Syntax:</span></div></div><div class="WaaZC" id="bkmrk-code" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ9MILegQIFxAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div>```
array array_filter(array $array, callable $callback = null, int $flag = 0)
```

<div class="WaaZC" id="bkmrk-parameters%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBkQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegQIGRAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="7541767305775624929">Parameters:</span></div></div><div class="WaaZC" id="bkmrk-%24array%C2%A0%28required%29%3A%C2%A0t" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">- <span data-huuid="7541767305775625772">`$array` (required): </span><span data-huuid="7541767305775626053">The input array to be filtered.</span>
- <span data-huuid="7541767305775626615">`$callback` (optional): </span><span data-huuid="7541767305775626896">A callable function that defines the condition for filtering. </span><span data-huuid="7541767305775627177">If omitted, all entries of the array that evaluate to `FALSE` will be removed.<span class="pjBG2e" data-cid="28239005-f6f1-4f2a-afda-51474b369503"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="28239005-f6f1-4f2a-afda-51474b369503" data-uuids="7541767305775626615,7541767305775626896,7541767305775627177" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CCsQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ3fYKegQIKxAB" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-flex !important; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(229, 237, 255) !important; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div>

<div class="bsmXxe" id="bkmrk-%24flag%C2%A0%28optional%29%3A%C2%A0an" role="none" style="display: contents;"><span data-huuid="7541767305775627739">`$flag` (optional): </span><span data-huuid="7541767305775628020">An integer value that specifies additional behavior for the callback function.<span class="pjBG2e" data-cid="eee03571-f56c-489d-9d17-a75ba21b1cf7"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="eee03571-f56c-489d-9d17-a75ba21b1cf7" data-uuids="7541767305775627739,7541767305775628020" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CH4QAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ3fYKegQIfhAB" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-flex !important; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(229, 237, 255) !important; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div><div class="bsmXxe" id="bkmrk-array_filter_use_key" role="none" style="display: contents;"><div class="bsmXxe" id="bkmrk-array_filter_use_key-1" role="none" style="display: contents;"><span data-huuid="7541767305775624767">`ARRAY_FILTER_USE_KEY`: Passes the key as the only argument to the callback.<span class="pjBG2e" data-cid="7610d2af-a501-4f37-ad0f-738c89b631e6"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="7610d2af-a501-4f37-ad0f-738c89b631e6" data-uuids="7541767305775624767" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CIkBEAE" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ3fYKegUIiQEQAQ" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-flex !important; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(229, 237, 255) !important; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div></div><div class="bsmXxe" id="bkmrk-array_filter_use_bot" role="none" style="display: contents;"><span data-huuid="7541767305775625329">`ARRAY_FILTER_USE_BOTH`: Passes both the value and the key as arguments to the callback.<span class="pjBG2e" data-cid="0c555822-fa3e-412f-875a-f674118d248f"><span class="UV3uM" style="white-space: nowrap;"> </span></span></span><div class="NPrrbc" data-cid="0c555822-fa3e-412f-875a-f674118d248f" data-uuids="7541767305775625329" style="margin-inline-end: 6px; vertical-align: middle; display: inline-flex;"><div aria-label="View related links" class="BMebGe btku5b LwdV0e FR7ZSc OJeuxf" data-hveid="CIwBEAE" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ3fYKegUIjAEQAQ" jsaction="KjsqPd" jsname="HtgYJd" role="button" style="display: inline-flex !important; vertical-align: middle; cursor: pointer; outline: 0px; -webkit-tap-highlight-color: transparent; color: rgb(28, 65, 154);" tabindex="0"><div class="niO4u" style="display: flex; justify-content: center; position: relative; align-items: center; width: 28px; z-index: 0; box-sizing: border-box; border-radius: 9999px; padding: 0px; border: 1px solid transparent; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(229, 237, 255) !important; height: 20px; margin: 0px auto; min-height: 20px;"><span class="TwMgNb Hkv2Pe" style="color: rgb(31, 31, 31) !important; background: unset !important; display: flex; align-items: center;"><span class="iPjmzb Sorfoc gNGSDf" style="display: flex; height: unset; rotate: 135deg;"><span class="z1asCe Sb7k4e" style="display: inline-block; fill: currentcolor; height: 18px; line-height: 18px; position: relative; width: 18px;"><svg aria-hidden="true" focusable="false" viewbox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></svg></span></span></span></div></div></div></div></div></div></div><div class="WaaZC" id="bkmrk-how-it-works%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="bsmXxe" id="bkmrk-how-it-works%3A-1" role="none" style="display: contents;"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CHkQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegQIeRAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="5962802332984482174">How it works:</span></div></div></div><div class="WaaZC" id="bkmrk-the%C2%A0array_filter%28%29%C2%A0f-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="bsmXxe" id="bkmrk-the%C2%A0array_filter%28%29%C2%A0f-2" role="none" style="display: contents;"><div class="rPeykc" data-hveid="CIMBEAE" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegUIgwEQAQ" style="margin: 10px 0px;"><span data-huuid="5962802332984480344">The `array_filter()` function iterates through each element of the `$array`. </span><span data-huuid="5962802332984483525">For each element, it calls the `$callback` function, passing the element's value (and optionally its key, depending on the `$flag`) as arguments. </span><span data-huuid="5962802332984482610">If the `$callback` function returns `true`, the element is included in the new array returned by `array_filter()`. </span><span data-huuid="5962802332984481695">If `false` is returned, the element is excluded. </span><span data-huuid="5962802332984480780">Array keys are preserved in the filtered array.</span></div></div></div><div class="WaaZC" id="bkmrk-example%3A" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="bsmXxe" id="bkmrk-example%3A-1" role="none" style="display: contents;"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CHgQAQ" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQo_EKegQIeBAB" role="heading" style="margin: 20px 0px 10px; font-size: 20px; font-weight: 600; line-height: 28px;"><span data-huuid="8904727753496886501">Example:</span></div></div></div><div class="WaaZC" id="bkmrk-code-1" style="color: rgb(10, 10, 10); font-family: 'Google Sans', Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><div class="bsmXxe" role="none" style="display: contents;"><div jsaction="rcuQ6b:npT2md" jscontroller="JegcYe"><div class="ecCNFc" style="border-image: none 100% / 1 / 0 stretch; border-radius: 8px; font-size: 14px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5); margin-bottom: 20px; color: rgb(10, 10, 10); border: 0.8px solid rgb(169, 172, 170);"><div class="zYSUYd" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0px 0px;"><div class="FS7GEb" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"><div class="dDrxod" style="height: 34px; display: flex; justify-content: space-between; align-items: center; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(229, 237, 255); border-bottom: 0.8px solid rgb(169, 172, 170);"><div class="x7ndcb" style="padding-left: 16px; display: flex; align-items: center; color: rgb(10, 10, 10);">Code</div><div aria-live="polite" class="WDoJJe" style="margin-right: 4px; display: flex; align-items: center;"><button aria-label="Copy code to clipboard" class="hqI3tf B4zsNc" data-ved="2ahUKEwiI-57mrZyRAxWtRmwGHS_bEKUQ9MILegQIdBAB" role="button" style="margin: 0px 2px; background: none; height: 34px; border: none; color: rgb(5, 40, 97); position: relative; top: 2px; outline: 0px;" tabindex="0" title="Copy"><span class="z1asCe wm4nBd" style="display: inline-block; fill: currentcolor; height: 20px; line-height: 20px; position: relative; width: 20px;"><svg aria-hidden="true" enable-background="new 0 0 24 24" focusable="false" height="24" viewbox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M16,20H5V6H3v14c0,1.1,0.9,2,2,2h11V20z M20,16V4c0-1.1-0.9-2-2-2H9C7.9,2,7,2.9,7,4v12c0,1.1,0.9,2,2,2h9 C19.1,18,20,17.1,20,16z M18,16H9V4h9V16z"></path></g></svg></span></button></div></div></div></div><div class="QQjpRc" style="display: flex; flex-direction: row; overflow: hidden; border-radius: 0px 0px 8px 8px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(245, 248, 255, 0.5);"><div class="FS7GEb" jsname="zEXxAd" style="display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 518.4px;"></div></div></div></div></div></div>```
<?php
$numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Filter out odd numbers (keep even numbers)
$even_numbers = array_filter($numbers, function($number) {
    return $number % 2 === 0;
});

print_r($even_numbers);

// Output:
// Array
// (
//     [1] => 2
//     [3] => 4
//     [5] => 6
//     [7] => 8
//     [9] => 10
// )

$data = [
    'name' => 'John Doe',
    'email' => '',
    'age' => 30,
    'city' => null
];

// Filter out empty or null values
$filtered_data = array_filter($data);

print_r($filtered_data);

// Output:
// Array
// (
//     [name] => John Doe
//     [age] => 30
// )
?>
```