Core Function IsIndexSet

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> IndexSet( <array>, <index> ) </pre> === Description === Check if an element exist at a given index ID within an array. === Parameters === ==== array ==== The array to ...")
 
m (1 revision)
 
(5 intermediate revisions by one user not shown)
Line 25: Line 25:
 
=== Remarks ===
 
=== Remarks ===
  
None
+
Alias' for this command
 +
<pre>
 +
IsKeySet()
 +
</pre>
  
 
=== Example ===
 
=== Example ===
Line 41: Line 44:
 
println( "Index 1 is : " . (IsIndexSet($a, 1) ? "SET" : "NOT SET") );
 
println( "Index 1 is : " . (IsIndexSet($a, 1) ? "SET" : "NOT SET") );
 
println( "Index 2 is : " . (IsIndexSet($a, 2) ? "SET" : "NOT SET") );
 
println( "Index 2 is : " . (IsIndexSet($a, 2) ? "SET" : "NOT SET") );
 +
</syntaxhighlight>
 +
 +
Alternative way using IsSet()
 +
 +
<syntaxhighlight lang="sputnik">
 +
IsSet($a) # Check if $a is set
 +
IsSet($a['Test']) # Check if $a (as array) index 'Test' is set
 +
IsSet($a['Test']['Cat']) # Check if $a (as array) index 'Test' (as array) index 'Cat' is set
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Latest revision as of 12:37, 14 June 2015

IndexSet( <array>, <index> )

Contents

Description

Check if an element exist at a given index ID within an array.

Parameters

array

The array to use.

index

The index to check (starts at 0).

Return Value

Success - Returns 1.

Failure - Returns 0.

Remarks

Alias' for this command

IsKeySet()

Example

$a = array("One", "Two");
 
println( "Index 0 is : " . (IsIndexSet($a, 0) ? "SET" : "NOT SET") );
println( "Index 1 is : " . (IsIndexSet($a, 1) ? "SET" : "NOT SET") );
println( "Index 2 is : " . (IsIndexSet($a, 2) ? "SET" : "NOT SET") );
 
// Delete an index and do it again
unset($a[1]);
println( "Index 0 is : " . (IsIndexSet($a, 0) ? "SET" : "NOT SET") );
println( "Index 1 is : " . (IsIndexSet($a, 1) ? "SET" : "NOT SET") );
println( "Index 2 is : " . (IsIndexSet($a, 2) ? "SET" : "NOT SET") );

Alternative way using IsSet()

IsSet($a) # Check if $a is set
IsSet($a['Test']) # Check if $a (as array) index 'Test' is set
IsSet($a['Test']['Cat']) # Check if $a (as array) index 'Test' (as array) index 'Cat' is set
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox