Archive

- Posts Tagged ‘array’

PHP Session Array

In beginning, programmer think whether they can store array or not in PHP session. Yes, you can store array in php session. You store values in session for getting it latter on any page of PHP application. session_start() need to be present on that page to get the stored values… (Continue)

More on Associative Array in Javascript

In this article about associative array, which looks similar to associative array in PHP. Here is some more ways for simulating associative array like things in Javascript: <script type="text/javascript"> var obj = new Object(); obj['name'] = 'satya'; obj['sex'] = 'male'; obj['city'] = 'Patna'; obj['age'] = '30'; // this method is… (Continue)

Associative array in Javascript

Javascript do not have associative array like PHP. In PHP you may have enjoyed associative array. Here is something similar to associative array in JavaScript. But as it is not an associative array, so you cannot use JavaScript array methods. It is JSON style Object representation. <script type="text/javascript"> var salesPerson… (Continue)

Search in Key/ Index of an Associative PHP Array

I have to search in keys of associative PHP Array and not in value of an array. I want it to be fast as I need to search in long list and find something. PHP function array_search() search in array's value part. I got three methods which have provided working… (Continue)

Check and Remove Duplicate Values from PHP Array

I want to check whether my array holds duplicate entry and if it holds duplicate values then remove those duplicate value. This code will directly remove the duplicate value from an Array. 1. Remove duplicate values from an array <?php $arrUnique = array_unique ($array1); ?> This array_unique function work in… (Continue)

PHP array – Common Usage

You will use "print_r" and "foreach" many times during programming at the time of using array. <?php $arr3 = array('a', 'b', 'c', 'd'); echo '<pre>'; print_r($arr2); echo '</pre>'; ?> print_r() will print whole array with key=>value pair in human readable format. Delete every item, but not array foreach ($arr3 as… (Continue)

Array in PHP

Array Syntax: array ([key=>] value,) Key may be an integer or string, and value may be any value. <?php $arr1 = array ('lang'=>'php', 1=>true, 13); echo $arr1['lang'] ; // print php echo $arr1[1]; // 1 echo $arr1[2]; // 13 ?> As you can see above string 'key' is quoted. An… (Continue)

Set/Get Cookie using PHP and JavaScript

Find variety of codes and details discussion about the cookie both using JavaScript and PHP: Set cookie through PHP and get through JavaScript Set cookie through JavaScript and get through PHP Set cookie in JavaScript and get through JavaScript Set cookie through PHP and get through PHP Set the Array… (Continue)