Lasso Soft Inc. > Home

[ staticarray->findposition ]


The [staticarray->findposition] method searches the array for the parameter and returns an array of positions for those elements which match.

Accepts a single parameter of any data type including matchers. Optionally accepts a integer which is the offset position to begin searching the array at. If the array contains any pair values, only the first part of the pair is compared with the parameter of the [staticarray->findposition] method.

If no elements in the array match the parameter to the [staticarray->findposition] method, or the offset parameter is outside of the size of the array, then an empty array is returned.

Note: this method returns objects of type array.

  • Syntax

staticarray->findposition('search_term', offset)
  • Beginner

Find the positions of the element in an array

Example 1:

Return the positions that 'John Doe' occurs at in an array of names


var( myNames = staticarray('John Doe', 'Jane Doe', 'Wendy Buck', 'John Doe', 'Jim Stag') )

$myNames->findposition('John Doe')


array(1, 4)

Example 2:

Return the positions that John Doe occurs at in the array of name:position pairs after the first one.


var( myNames = staticarray('John Doe', 'Jane Doe', 'Wendy Buck', 'John Doe', 'Jim Stag') )

$myNames->findposition('John Doe', 2)



Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home



©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft