Showing posts with label Array. Show all posts
Showing posts with label Array. Show all posts

PHP Code : How to Check If Key Array Is Exist

5:02 PM | , , , , , , ,

Check if key array is exist with function array_key_exists

Syntax
bool array_key_exists ( mixed $key , array $array )
array_key_exists() returns TRUE if the given key is set in the array. key can be any value possible for an array index.

<?php
$search_array 
= array('first' => null'second' => 4);
// returns falseisset($search_array['first']);
// returns truearray_key_exists('first'$search_array);?>
Read More

Using JQuery Array

10:12 AM | , , , , , , , , ,

1. Array Push

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi")

The result of fruits will be:
Banana,Orange,Apple,Mango,Kiwi

2. Remove Array Elemen

var y = [1, 2, 3];
var removeItem = 2;

y = jQuery.grep(y, function(value) {
  return value != removeItem;
});
or
var y = [1, 2, 3];
var removeItem = 2;
y.splice( $.inArray(removeItem, y), 1 );
or
var y = [1, 2, 3];
y.remove(2);
The result of fruits will be:
1,3


Read More