solidity check if array contains

The solution for “solidity check if array contains” can be found here. The following code will assist you in solving the problem.

// either use a mapping

mapping(address => uint8) myMap;

// write a for loop (try not to do this unless have to)
// try not to use less or equal to, use less instead
// gas optimisation

for (uint256 i = 0; i < 1; i++) {
if (searchList[i] == “toFindString”) {
// do whatever

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts