Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( isset( $array['index'] ) {
- //Do something
- }
- if( array_key_exists( 'index', $array ) {
- //Do something
- }
- $aTestArray = array();
- echo "Before key is createdrn";
- echo "isset:rn";
- var_dump( isset( $aTestArray['TestKey'] ) );
- echo "array_key_exists:rn";
- var_dump( array_key_exists( 'TestKey', $aTestArray ) );
- echo "rn";
- $aTestArray['TestKey'] = NULL;
- echo "Key is created, but set to NULLrn";
- echo "isset:rn";
- var_dump( isset( $aTestArray['TestKey'] ) );
- echo "array_key_exists:rn";
- var_dump( array_key_exists( 'TestKey', $aTestArray ) );
- echo "rn";
- $aTestArray['TestKey'] = 0;
- echo "Key is created, and set to 0 (zero)rn";
- echo "isset:rn";
- var_dump( isset( $aTestArray['TestKey'] ) );
- echo "array_key_exists:rn";
- var_dump( array_key_exists( 'TestKey', $aTestArray ) );
- echo "rn";
- Before key is created
- isset:
- bool(false)
- array_key_exists:
- bool(false)
- Key is created, but set to NULL
- isset:
- bool(false)
- array_key_exists:
- bool(true)
- Key is created, and set to 0 (zero)
- isset:
- bool(true)
- array_key_exists:
- bool(true)
- foreach( $array as $key => value )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement