Saturday, February 7, 2026
HomeLanguagesPHP | DsVector contains() Function

PHP | Ds\Vector contains() Function

The Ds\Vector::contains() function is an inbuilt function in PHP which is used to check the vector contains given value or not.

Syntax:

bool public Ds\Vector::contains( $values )

Parameters: This function accepts a single parameter $values which contains single/many values.

Return Value: This function returns true if the given value exists, false otherwise.

Below programs illustrate the Ds\Vector::contains() function in PHP:

Program 1:




<?php
  
// Create a vector
$vector = new \Ds\Vector([1, 2, 3, 4, 5]);
  
// Use contains() function to check
// existence of vector elements
var_dump($vector->contains(1));
  
var_dump($vector->contains(1, 2));
  
var_dump($vector->contains(10));
  
?> 


Output:

bool(true)
bool(true)
bool(false)

Program 2:




<?php
  
// Create a vector
$vector = new \Ds\Vector(["neveropen", "for", "neveropen"]);
  
// Use contains() function to check
// existence of vector elements
var_dump($vector->contains("neveropen"));
  
var_dump($vector->contains("neveropen", "for"));
  
var_dump($vector->contains("GfG"));
  
?>


Output:

bool(true)
bool(true)
bool(false)

Reference: http://php.net/manual/en/ds-vector.contains.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32491 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6863 POSTS0 COMMENTS
Nicole Veronica
11987 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12076 POSTS0 COMMENTS
Shaida Kate Naidoo
6996 POSTS0 COMMENTS
Ted Musemwa
7238 POSTS0 COMMENTS
Thapelo Manthata
6947 POSTS0 COMMENTS
Umr Jansen
6933 POSTS0 COMMENTS