{"id":2060,"date":"2016-03-20T18:00:00","date_gmt":"2016-03-21T01:00:00","guid":{"rendered":"https:\/\/www.virendrachandak.com\/techtalk\/?p=2060"},"modified":"2016-03-26T15:00:10","modified_gmt":"2016-03-26T22:00:10","slug":"php-7-combined-comparison-spaceship-operator","status":"publish","type":"post","link":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/","title":{"rendered":"PHP 7 &#8211; Combined Comparison (Spaceship) Operator"},"content":{"rendered":"<p>In this post we will take a look and another new operator in PHP 7. This operator is the Combined Comparison or Spaceship operator (<code>&lt;=&gt;<\/code>). This operator is a three way comparison operator. It will do greater-than, less-than and equal comparisons between two operands. <\/p>\n<p>The spaceship operator (<code>&lt;=&gt;<\/code>) returns -1 if the left side is smaller, 0 if the values are equal and 1 if the left side is larger. It can be used on all generic PHP values with the same semantics as < , <=, ==, >=, >. This operator is similar in behavior to strcmp() or version_compare(). This operator can be used with integers, floats, strings, arrays, objects, etc.<br \/>\n<!--more--><br \/>\nExample usage:<\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n$c = $a &lt;=&gt; $b;\r\n\/\/ This is equivalent to\r\n$c = ($a &lt; $b) ? -1 : (($a &gt; $b) ? 1 : 0);\r\n<\/pre>\n<p>Here are a few more examples from <a href=\"https:\/\/wiki.php.net\/rfc\/combined-comparison-operator\" target=\"_blank\">PHP RFP for Combined Comparison (Spaceship) Operator<\/a><\/p>\n<pre class=\"brush: php; gutter: false; title: ; notranslate\" title=\"\">\r\n\/\/ Integers\r\necho 1 &lt;=&gt; 1; \/\/ 0\r\necho 1 &lt;=&gt; 2; \/\/ -1\r\necho 2 &lt;=&gt; 1; \/\/ 1\r\n \r\n\/\/ Floats\r\necho 1.5 &lt;=&gt; 1.5; \/\/ 0\r\necho 1.5 &lt;=&gt; 2.5; \/\/ -1\r\necho 2.5 &lt;=&gt; 1.5; \/\/ 1\r\n \r\n\/\/ Strings\r\necho &quot;a&quot; &lt;=&gt; &quot;a&quot;; \/\/ 0\r\necho &quot;a&quot; &lt;=&gt; &quot;b&quot;; \/\/ -1\r\necho &quot;b&quot; &lt;=&gt; &quot;a&quot;; \/\/ 1\r\n \r\necho &quot;a&quot; &lt;=&gt; &quot;aa&quot;; \/\/ -1\r\necho &quot;zz&quot; &lt;=&gt; &quot;aa&quot;; \/\/ 1\r\n \r\n\/\/ Arrays\r\necho &#x5B;] &lt;=&gt; &#x5B;]; \/\/ 0\r\necho &#x5B;1, 2, 3] &lt;=&gt; &#x5B;1, 2, 3]; \/\/ 0\r\necho &#x5B;1, 2, 3] &lt;=&gt; &#x5B;]; \/\/ 1\r\necho &#x5B;1, 2, 3] &lt;=&gt; &#x5B;1, 2, 1]; \/\/ 1\r\necho &#x5B;1, 2, 3] &lt;=&gt; &#x5B;1, 2, 4]; \/\/ -1\r\n \r\n\/\/ Objects\r\n$a = (object) &#x5B;&quot;a&quot; =&gt; &quot;&lt;span class=&quot;hiddenGrammarError&quot; pre=&quot;&quot;&gt;&lt;span class=&quot;hiddenGrammarError&quot; pre=&quot;&quot;&gt;b&quot;]; \r\n$b&lt;\/span&gt;&lt;\/span&gt; = (object) &#x5B;&quot;a&quot; =&gt; &quot;b&quot;]; \r\necho $a &lt;=&gt; $b; \/\/ 0\r\n \r\n$a = (object) &#x5B;&quot;a&quot; =&gt; &quot;b&quot;]; \r\n$b = (object) &#x5B;&quot;a&quot; =&gt; &quot;c&quot;]; \r\necho $a &lt;=&gt; $b; \/\/ -1\r\n \r\n$a = (object) &#x5B;&quot;a&quot; =&gt; &quot;c&quot;]; \r\n$b = (object) &#x5B;&quot;a&quot; =&gt; &quot;b&quot;]; \r\necho $a &lt;=&gt; $b; \/\/ 1\r\n \r\n\/\/ only values are compared\r\n$a = (object) &#x5B;&quot;a&quot; =&gt; &quot;b&quot;]; \r\n$b = (object) &#x5B;&quot;b&quot; =&gt; &quot;b&quot;]; \r\necho $a &lt;=&gt; $b; \/\/ 0\r\n<\/pre>\n<p>More reading:<br \/>\n<a href=\"https:\/\/wiki.php.net\/rfc\/combined-comparison-operator\" target=\"_blank\">PHP RFP for Combined Comparison (Spaceship) Operator<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post we will take a look and another new operator in PHP 7. This operator is the Combined Comparison or Spaceship operator (&lt;=&gt;). This operator is a three way comparison operator. It will do greater-than, less-than and equal comparisons between two operands. The spaceship operator (&lt;=&gt;) returns -1 if the left side is [&hellip;]<\/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,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"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-2060","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.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PHP 7 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk<\/title>\n<meta name=\"description\" content=\"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands\" \/>\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\/php-7-combined-comparison-spaceship-operator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP 7 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk\" \/>\n<meta property=\"og:description\" content=\"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-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=\"2016-03-21T01:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-26T22:00:10+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/\"},\"author\":{\"name\":\"Virendra Chandak\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"headline\":\"PHP 7 &#8211; Combined Comparison (Spaceship) Operator\",\"datePublished\":\"2016-03-21T01:00:00+00:00\",\"dateModified\":\"2016-03-26T22:00:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/\"},\"wordCount\":373,\"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\\\/php-7-combined-comparison-spaceship-operator\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/\",\"url\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/\",\"name\":\"PHP 7 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#website\"},\"datePublished\":\"2016-03-21T01:00:00+00:00\",\"dateModified\":\"2016-03-26T22:00:10+00:00\",\"description\":\"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-operator\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/php-7-combined-comparison-spaceship-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 &#8211; Combined Comparison (Spaceship) 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 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk","description":"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands","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\/php-7-combined-comparison-spaceship-operator\/","og_locale":"en_US","og_type":"article","og_title":"PHP 7 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk","og_description":"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands","og_url":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-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":"2016-03-21T01:00:00+00:00","article_modified_time":"2016-03-26T22:00:10+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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/#article","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/"},"author":{"name":"Virendra Chandak","@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"headline":"PHP 7 &#8211; Combined Comparison (Spaceship) Operator","datePublished":"2016-03-21T01:00:00+00:00","dateModified":"2016-03-26T22:00:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/"},"wordCount":373,"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\/php-7-combined-comparison-spaceship-operator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/","url":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/","name":"PHP 7 - Combined Comparison (Spaceship) Operator - Virendra&#039;s TechTalk","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#website"},"datePublished":"2016-03-21T01:00:00+00:00","dateModified":"2016-03-26T22:00:10+00:00","description":"Combined Comparison or Spaceship operator is a three way comparison operator which will do greater-than, less-than and equal comparisons between 2 operands","breadcrumb":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-operator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-combined-comparison-spaceship-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 &#8211; Combined Comparison (Spaceship) 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-xe","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2375,"url":"https:\/\/www.virendrachandak.com\/techtalk\/null_coalesce_equal_operator\/","url_meta":{"origin":2060,"position":0},"title":"PHP 7.4 &#8211; Null Coalesce Assignment Operator","author":"Virendra Chandak","date":"December 22, 2019","format":false,"excerpt":"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.","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":2058,"url":"https:\/\/www.virendrachandak.com\/techtalk\/php-7-null-coalesce-operator\/","url_meta":{"origin":2060,"position":1},"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":1972,"url":"https:\/\/www.virendrachandak.com\/techtalk\/how-to-sort-a-multi-dimension-array-by-value-in-php\/","url_meta":{"origin":2060,"position":2},"title":"How to sort a multi-dimension array by value in PHP","author":"Virendra Chandak","date":"February 16, 2015","format":false,"excerpt":"In this article we will see how to sort a multi-dimension array by value of one of the keys of the array. We can use a few different methods to do this. One way to to use usort() function. Another way is to just identify the values and create another\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":688,"url":"https:\/\/www.virendrachandak.com\/techtalk\/php-isset-vs-empty-vs-is_null\/","url_meta":{"origin":2060,"position":3},"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":2196,"url":"https:\/\/www.virendrachandak.com\/techtalk\/using-php-bcrypt-algorithm-for-htpasswd-generation\/","url_meta":{"origin":2060,"position":4},"title":"Generating bcrypt .htpasswd passwords using PHP","author":"Virendra Chandak","date":"September 23, 2019","format":false,"excerpt":"In my previous post we saw how to generate .htpasswd file using crypt and apr1-md5 algorithm in PHP. However, now there is a more secure BCRYPT algorithm that can be used since apache 2.4 for passwords in .htpasswd. In this post we will generate .htpasswd file using the BCRYPT algorithm\u2026","rel":"","context":"In &quot;Security&quot;","block_context":{"text":"Security","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/security\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":450,"url":"https:\/\/www.virendrachandak.com\/techtalk\/getting-real-client-ip-address-in-php-2\/","url_meta":{"origin":2060,"position":5},"title":"Getting real client IP address in PHP","author":"Virendra Chandak","date":"October 23, 2011","format":false,"excerpt":"Many times we need the visitor's ipaddress for validation, security, spam prevention, etc. Getting the Visitor's ipaddress is very easy in PHP. The simplest way to get the visitor's\/client's ipaddress is using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. The variable in the $_SERVER array are created by the web server (like\u2026","rel":"","context":"In &quot;Functionality&quot;","block_context":{"text":"Functionality","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/functionality\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2060","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=2060"}],"version-history":[{"count":0,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2060\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/media?parent=2060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/categories?post=2060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/tags?post=2060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}