{"id":2375,"date":"2019-12-22T16:57:01","date_gmt":"2019-12-23T00:57:01","guid":{"rendered":"https:\/\/www.virendrachandak.com\/techtalk\/?p=2375"},"modified":"2020-04-05T15:43:20","modified_gmt":"2020-04-05T22:43:20","slug":"null_coalesce_equal_operator","status":"publish","type":"post","link":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","title":{"rendered":"PHP 7.4 &#8211; Null Coalesce Assignment Operator"},"content":{"rendered":"<p>PHP 7.4 added a new Null Coalesce Assignment Operator (??=) which is an enhancement of <a href=\"https:\/\/www.virendrachandak.com\/techtalk\/php-7-null-coalesce-operator\/\" target=\"_blank\" rel=\"noopener noreferrer\">Null Coalesce Operator (??)<\/a> introduced in PHP 7. The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. If the left-hand parameter is not null then its value is not changed. The Null Coalesce Assignment Operator is sometimes also called as Null Coalesce Equal Operator.<br \/>\n<!--more--><\/p>\n<p>The Null coalesce operator (??) was added so that instead of using isset() along with the ternary operator (?:) we could just use the null coalesce operator (??). Here is an example usage:<\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n\/\/ Fetches the value of $_GET&#x5B;'user'] \r\n\/\/ and returns 'nobody' if it does not exist.\r\n$_GET&#x5B;'user'] = $_GET&#x5B;'user'] ?? 'nobody';\r\n\/\/ This is equivalent to:\r\n$_GET&#x5B;'user'] = isset($_GET&#x5B;'user']) ? $_GET&#x5B;'user'] : 'nobody';\r\n<\/pre>\n<p>The Null Coalesce Assignment Operator can now simplify the above statement even further as follows:<\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n$_GET&#x5B;'user'] ??= 'nobody';\r\n<\/pre>\n<p>This operator is useful if you can checking if the value of variable is null and want to assign it some other value in that case. However, this operator does not works if you are trying to assign the values to a different variable. So, for example in the following case you cannot use the Null Coalesce Assignment Operator, but you can still use Null Coalesce Operator.<\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n$username = $_GET&#x5B;'user'] ?? 'nobody';\r\n<\/pre>\n<p>More reading:<br \/>\n<a href=\"https:\/\/wiki.php.net\/rfc\/null_coalesce_equal_operator\" target=\"_blank\" rel=\"noopener noreferrer\">PHP RFC: Null Coalescing Assignment Operator<\/a><br \/>\n<a href=\"https:\/\/www.virendrachandak.com\/techtalk\/php-7-null-coalesce-operator\/\" target=\"_blank\" rel=\"noopener noreferrer\">Null Coalesce Operator (??)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[143],"tags":[149],"class_list":["post-2375","post","type-post","status-publish","format-standard","hentry","category-php","tag-php-7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk<\/title>\n<meta name=\"description\" content=\"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk\" \/>\n<meta property=\"og:description\" content=\"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/\" \/>\n<meta property=\"og:site_name\" content=\"Virendra&#039;s TechTalk\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/virendrachandak\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/virendrachandak\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-23T00:57:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-05T22:43:20+00:00\" \/>\n<meta name=\"author\" content=\"Virendra Chandak\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@virendrachandak\" \/>\n<meta name=\"twitter:site\" content=\"@virendrachandak\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virendra Chandak\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/\"},\"author\":{\"name\":\"Virendra Chandak\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"headline\":\"PHP 7.4 &#8211; Null Coalesce Assignment Operator\",\"datePublished\":\"2019-12-23T00:57:01+00:00\",\"dateModified\":\"2020-04-05T22:43:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/\"},\"wordCount\":249,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"keywords\":[\"PHP 7\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/\",\"url\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/\",\"name\":\"PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#website\"},\"datePublished\":\"2019-12-23T00:57:01+00:00\",\"dateModified\":\"2020-04-05T22:43:20+00:00\",\"description\":\"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/null_coalesce_equal_operator\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"TechTalk\",\"item\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/category\\\/php\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP 7.4 &#8211; Null Coalesce Assignment Operator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#website\",\"url\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/\",\"name\":\"Virendra's TechTalk\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\",\"name\":\"Virendra Chandak\",\"logo\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.virendrachandak.com\",\"https:\\\/\\\/www.facebook.com\\\/virendrachandak\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/virendrachandak\\\/\",\"https:\\\/\\\/x.com\\\/virendrachandak\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk","description":"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.","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:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","og_locale":"en_US","og_type":"article","og_title":"PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk","og_description":"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.","og_url":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","og_site_name":"Virendra&#039;s TechTalk","article_publisher":"https:\/\/www.facebook.com\/virendrachandak","article_author":"https:\/\/www.facebook.com\/virendrachandak","article_published_time":"2019-12-23T00:57:01+00:00","article_modified_time":"2020-04-05T22:43:20+00:00","author":"Virendra Chandak","twitter_card":"summary_large_image","twitter_creator":"@virendrachandak","twitter_site":"@virendrachandak","twitter_misc":{"Written by":"Virendra Chandak","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/#article","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/"},"author":{"name":"Virendra Chandak","@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"headline":"PHP 7.4 &#8211; Null Coalesce Assignment Operator","datePublished":"2019-12-23T00:57:01+00:00","dateModified":"2020-04-05T22:43:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/"},"wordCount":249,"commentCount":0,"publisher":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"keywords":["PHP 7"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","url":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","name":"PHP 7.4 - Null Coalesce Assignment Operator - Virendra&#039;s TechTalk","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#website"},"datePublished":"2019-12-23T00:57:01+00:00","dateModified":"2020-04-05T22:43:20+00:00","description":"The Null Coalesce Assignment Operator (??=) assigns the value of the right-hand parameter if the left-hand parameter is null. It is also called as Null Coalesce Equal Operator.","breadcrumb":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"TechTalk","item":"https:\/\/www.virendrachandak.com\/techtalk\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.virendrachandak.com\/techtalk\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP 7.4 &#8211; Null Coalesce Assignment Operator"}]},{"@type":"WebSite","@id":"https:\/\/www.virendrachandak.com\/techtalk\/#website","url":"https:\/\/www.virendrachandak.com\/techtalk\/","name":"Virendra's TechTalk","description":"","publisher":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.virendrachandak.com\/techtalk\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17","name":"Virendra Chandak","logo":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.virendrachandak.com","https:\/\/www.facebook.com\/virendrachandak","https:\/\/www.linkedin.com\/in\/virendrachandak\/","https:\/\/x.com\/virendrachandak"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2vTtQ-Cj","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2058,"url":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-null-coalesce-operator\/","url_meta":{"origin":2375,"position":0},"title":"PHP 7 &#8211; Null Coalesce Operator","author":"Virendra Chandak","date":"November 1, 2015","format":false,"excerpt":"PHP 7 brings a lot of improvements, features and new operators as compared to the earlier versions on PHP. One of the new operators is the Null Coalesce Operator (??). This operator can be used instead of using isset() along with the ternary operator (?:). The Null coalesce operator (??)\u2026","rel":"","context":"In &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/php\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":802,"url":"https:\/\/www.virendrachandak.com\/techtalk\/voting-functionality-in-a-website\/","url_meta":{"origin":2375,"position":1},"title":"Voting Functionality in a website","author":"Virendra Chandak","date":"April 10, 2011","format":false,"excerpt":"In this post I will give the step by step explanation of how we can add Voting Functionality to a website. At the end of this article we will have a working sample voting application. The source code for the sample voting application can be downloaded from here. We will\u2026","rel":"","context":"In &quot;Functionality&quot;","block_context":{"text":"Functionality","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/functionality\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virendrachandak.com\/techtalk\/wp-content\/uploads\/2011\/10\/initial.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":688,"url":"https:\/\/www.virendrachandak.com\/techtalk\/php-isset-vs-empty-vs-is_null\/","url_meta":{"origin":2375,"position":2},"title":"PHP isset() vs empty() vs is_null()","author":"Virendra Chandak","date":"January 21, 2012","format":false,"excerpt":"PHP has different functions which can be used to test the value of a variable. Three useful functions for this are isset(), empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results. isset() and empty() are\u2026","rel":"","context":"In &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/php\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2060,"url":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/","url_meta":{"origin":2375,"position":3},"title":"PHP 7 &#8211; Combined Comparison (Spaceship) Operator","author":"Virendra Chandak","date":"March 20, 2016","format":false,"excerpt":"In this post we will take a look and another new operator in PHP 7. This operator is the Combined Comparison or Spaceship operator (<=>). This operator is a three way comparison operator. It will do greater-than, less-than and equal comparisons between two operands. The spaceship operator (<=>) returns -1\u2026","rel":"","context":"In &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/php\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1997,"url":"https:\/\/www.virendrachandak.com\/techtalk\/mysql-int11-what-does-it-means\/","url_meta":{"origin":2375,"position":4},"title":"What does int(11) means in MySQL?","author":"Virendra Chandak","date":"August 10, 2016","format":false,"excerpt":"A very common misconception about what int(11) means in MySQL is that the column can store maximum integer value with 11 digits in length. However, this is not true. int(11) does not determines the maximum value that the column can store in it. 11 is the display width of the\u2026","rel":"","context":"In &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1086,"url":"https:\/\/www.virendrachandak.com\/techtalk\/how-to-apply-a-function-to-every-array-element-in-php\/","url_meta":{"origin":2375,"position":5},"title":"How to apply a function to every array element in PHP","author":"Virendra Chandak","date":"October 21, 2012","format":false,"excerpt":"I often come across situations in which I need to apply some function to every element of an array in PHP. For example, to sanitize the user input, function like htmlentities can be used. We can easily use this function on a single variable or a single dimension array by\u2026","rel":"","context":"In &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/php\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/comments?post=2375"}],"version-history":[{"count":0,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2375\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/media?parent=2375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/categories?post=2375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/tags?post=2375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}