arrayutils
  • Home
  • 📖How to use?
    • âš¡Installation
  • 📖Methods
    • âš¡Static method
      • static from()
      • static of()
      • static mapToArray()
    • âš¡Generic method
      • join()
      • every()
      • some()
      • reduce()
        • reduceRight()
      • sum()
      • pop()
      • shift()
      • includes()
      • keyExists()
      • indexOf()
      • find()
        • findIndex()
      • first()
        • keyFirst()
      • last()
        • keyLast()
      • random()
        • keyRandom()
      • splice()
    • âš¡Chain method
      • chunk()
      • column()
      • combine()
      • concat()
        • concatSoft()
      • countValues()
      • diff()
        • diffAssoc()
        • diffKey()
      • fill()
        • fillKeys()
      • filter()
      • flat()
        • flatMap()
      • flip()
      • forEach()
      • intersect()
        • intersectAssoc()
        • intersectKey()
      • keys()
      • map()
        • mapAssoc()
        • mapKey()
      • pad()
      • push()
      • replace()
      • reverse()
      • slice()
      • sort()
        • sortKey()
      • unique()
      • unshift()
      • values()
  • 📖Suffixes
    • âš¡Suffix - From
    • âš¡Suffix - As
  • links
    • 📌Github repo
    • 📌Packagist project
    • 📌Poggit project
Powered by GitBook
On this page
  • Syntax
  • Parameter
  • Return value
  • Prefixing
  • References
  1. 📖Methods
  2. ⚡Generic method

includes()

The includes() method tests whether an array includes a certain value among its entries

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["Apple", "Banana", "Carrot"]);

//Check array includes "Banana"
$arrayUtils->includes("Banana");
// expected output: true

//Check array includes "Banana" from 2
$arrayUtils->includes("Banana", 2);
// expected output: false

//Check array includes "Baccon"
$arrayUtils->includes("Baccon");
// expected output: false

Syntax

$arrayUtils->includes(mixed $needle, int $start = 0) : bool;

Parameter

  • $needle

    • The value to search for.

    • The position in this array at which to begin searching for valueToFind.

    • Defaults to 0.

Return value

  • A boolean the whether the element exists in the array

Prefixing

ArrayUtils::includesFrom(iterable $from, mixed $needle, int $start = 0) : bool;

References

Previousshift()NextkeyExists()

Last updated 2 years ago

$start

PHP: in_array - Manual
Logo
Array.prototype.includes() - JavaScript | MDN
Logo