{"id":1485,"date":"2023-05-21T08:27:25","date_gmt":"2023-05-21T08:27:25","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1485"},"modified":"2023-05-21T08:27:25","modified_gmt":"2023-05-21T08:27:25","slug":"how-can-you-search-and-get-the-index-of-a-value-in-an-array","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/how-can-you-search-and-get-the-index-of-a-value-in-an-array\/","title":{"rendered":"How can you search and get the index of a value in an array?"},"content":{"rendered":"\n<p>With this operation, you can search for an item in an array based on its value. This method accepts only one argument, value. It is a non-destructive method, which means it does not affect the array values.<\/p>\n\n\n\n<p><strong>The syntax is<\/strong><\/p>\n\n\n\n<p><code>arrayName.index(value)<\/code><\/p>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<p>Let\u2019s find the value of \u201c3\u201d in the array. This method returns the index of the searched value.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import array as myarray\nnumber = myarray.array('b', [2, 3, 4, 5, 6])              \nprint(number.index(3))<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With this operation, you can search for an item in an array based on its&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1485"}],"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=1485"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1485\/revisions"}],"predecessor-version":[{"id":1486,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1485\/revisions\/1486"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}