Core Function IsKeySet

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> IsKeySet( <array>, <key> ) </pre> === Description === Check if given key exists within an array (hash/dictionary). === Parameters === ==== array ==== The array to use....")
 
Line 26: Line 26:
  
 
This cannot be used to check if a array index exists for that use IsIndexSet() instead.
 
This cannot be used to check if a array index exists for that use IsIndexSet() instead.
 +
 +
Alias' for this command
 +
<pre>
 +
IsIndexSet()
 +
</pre>
  
 
=== Example ===
 
=== Example ===

Revision as of 12:49, 28 January 2013

IsKeySet( <array>, <key> )

Contents

Description

Check if given key exists within an array (hash/dictionary).

Parameters

array

The array to use.

key

The Key to check.

Return Value

Success - Returns 1.

Failure - Returns 0.

Remarks

This cannot be used to check if a array index exists for that use IsIndexSet() instead.

Alias' for this command

IsIndexSet()

Example

$a = array("One" => "FoX", "Two" => "Cat", "Three" => "Dog");
 
println( "Key[One] is : " . (IsKeySet($a, "One") ? "SET" : "NOT SET") );
println( "Key[Two] is : " . (IsKeySet($a, "Two") ? "SET" : "NOT SET") );
println( "Key[Three] is : " . (IsKeySet($a, "Three") ? "SET" : "NOT SET") );
println( "Key[Four] is : " . (IsKeySet($a, "Four") ? "SET" : "NOT SET") );
 
// Delete a key and do it again
unset($a["Two"]);
println( "Key[One] is : " . (IsKeySet($a, "One") ? "SET" : "NOT SET") );
println( "Key[Two] is : " . (IsKeySet($a, "Two") ? "SET" : "NOT SET") );
println( "Key[Three] is : " . (IsKeySet($a, "Three") ? "SET" : "NOT SET") );
println( "Key[Four] is : " . (IsKeySet($a, "Four") ? "SET" : "NOT SET") );
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox