Tag : Array


How to get keys name from array using array helper in PHP Laravel ?

Few days ago, I was working on my new Laravel 5.4 application and i require to get keys name from my array. i was thing how we can get it and laravel provide us for to do it. Finally i found array helper function in Laravel docs. There are several array helper function available for array. I found array_keys() helper for getting keys name from our array. array_keys() will return array of keys. It could be easy to work with keys name in array. So in this example i want to share with you small example using array_keys() helper. I created one route "myarraykeys" with my $myArray variable, and .....

By Hardik Savani | February 18, 2017 | | 536 Viewer | Category : PHP Laravel
READ MORE

AngularJS - convert comma separated string to array example

When i was working on my Laravel angularjs application, i require to make array from comma separated string, I was not expert in angularjs so i was thingking how is it possible ?, But Finally i was found solution using custom angularjs Filter. So, In this example, I will give you full example of how to convert comma separated string into array and how to print it. We will create array using split() of jquery. But if you know angularjs we can't do it anything directly from layout, So we should create our custom filter, as bellow you can see i created "customSplitString" filter. <strong>Filter:.....

By Hardik Savani | November 24, 2016 | | 1035 Viewer | Category : Bootstrap jQuery AngularJS
READ MORE

PHP - How to remove duplicate values from multidimensional array?

Sometimes, we require to remove duplicates value from multidimensional array in our PHP framework php like laravel, codeigniter, zend etc. Today, In this example i going to give you example of get unique values from multidimensional array that way duplicates will be delete. In this example i have simple multidimensional array with duplicates values array and i will perform to get only unique values from multidimensional. It is possible by core PHP array_map() and array_unique(). It helps to remove duplicates values from multidimensional array. So, first you can see bellow my multidimensional.....

By Hardik Savani | August 20, 2016 | | 1097 Viewer | Category : PHP
READ MORE

How to remove duplicate values from Array in PHP?

It is pretty simple to delete duplicate values from PHP Array. But sometimes we confuse for how can we remove. But PHP provide pre-define function array_unique that can help to remove duplicate values from Array. array_unique() through we can get only unique value from array. So, you can see bellow example i have 34 value two times but when i use array_unique() then it will return only unique value as bellow output: <strong>Example:</strong> <pre class="prettyprint lang-php"> $myArray = [11,34,56,78,34]; $myArrayNew = array_unique($myArray); print_r($myArrayNew); </pre> <strong>Output:</str.....

By Hardik Savani | July 14, 2016 | | 503 Viewer | Category : PHP
READ MORE

How to remove key from array in Laravel 5?

Sometimes, we require to delete specific key from array like we have password and confirm-password field but we don't require to store confirm-password field we have to drop that key from input array, At that time we always use unset() function of PHP pre-define. But if you work on laravel then you can array helper function. we can remove multiple key from variable using <strong class="path">array_except()</strong> of Laravel pre-define function. In bellow example you can understand very well. <strong>Example:</strong> <pre class="prettyprint lang-php"> $myArray = ['name'=>'HD','email'=>'te.....

By Hardik Savani | July 7, 2016 | | 1319 Viewer | Category : Laravel
READ MORE

How to get first element of array in Javascript?

Whenever you require to get first element value then you can use bellow example. I give you the way to get first element value in jquery. So let's see following example: <strong>Example</strong> <pre class="prettyprint lang-js"> <script type="text/javascript"> <br/> var languages = ["PHP", ".Net", "Java", "Javascript"]; <br/> var first_element = languages[0]; console.log(first_element); <br/> </script> </pre>

By Hardik Savani | April 18, 2016 | | 639 Viewer | Category : Javascript jQuery
READ MORE

How to get last element of array in Javascript?

Whenever you require to get last element value then you can use bellow example. I give you three way to get last element value in jquery. So let's see following example: <strong>Example</strong> <pre class="prettyprint lang-js"> <script type="text/javascript"> <br/> var languages = ["PHP", ".Net", "Java", "Javascript"]; <br/> var last_element = languages[languages.length-1]; console.log(last_element); <br/> var last_element2 = languages.pop(); console.log(last_element2); <br/> var last_element3 = languages.slice(-1)[0]; console.log(last_element3);.....

By Hardik Savani | April 16, 2016 | | 949 Viewer | Category : Javascript jQuery
READ MORE

How to set value as key in PHP array?

Sometimes, we work on big php or other framework projects and we need to change array value as array key at that time you can learn from this post. In this example you can do that without foreach loop. For example if you have all country array but that array have key like 1,2,3,4... etc and value is country. at that time you need to make array like country as key and value both that way you can store it on database table directly. We can do that using array_combine() of PHP array. array_combine() take two argument and both should be array. so, let's see exmple. <strong class="example">Examp.....

By Hardik Savani | April 8, 2016 | | 475 Viewer | Category : PHP
READ MORE

How to convert array key to lowercase in PHP?

Whenever you require to create all array key in lowercase then you can create that without using loop. you have to just use array_change_key_case(), array_change_key_case function take two argument one for array and second one for php function "CASE_LOWER". May be we need to do this when we are working on big projects and need to all key in small case. So, how to convert array values to lowercase using array_change_key_case(), see bellow example and learn how to work. <strong class="example">Example:</strong> <pre class="prettyprint lang-php"> $myArray = ['Hey'=>'Hey','HELLO'=>'Hello','hi'=>'.....

By Hardik Savani | April 6, 2016 | | 527 Viewer | Category : PHP
READ MORE

How to convert array values to lowercase in PHP?

Whenever you require to create all array value in lowercase then you can create that without using loop. you have to just use array_map(), array_map function take two argument one for php function "strtolower" and second one for array. May be we need to do this when we are working on big projects and need to all values in small case. So, how to convert array values to lowercase using array_map(), see bellow example and learn how to work. <strong class="example">Example:</strong> <pre class="prettyprint lang-php"> $myArray = ['1'=>'Hey','2'=>'Hello','3'=>'Hi','4'=>'GM']; $result = array_map('s.....

By Hardik Savani | April 5, 2016 | | 509 Viewer | Category : PHP
READ MORE

    Laravel 5 amazon s3 file upload tutorial - Part 1

    Laravel 5 amazon s3 file upload tutorial - Part 1

    Open Post

    Laravel 5.2 and AngularJS CRUD with Search and Pagination Example.

    Laravel 5.2 and AngularJS CRUD with Search and Pagination Example.

    Open Post

    Laravel 5 custom pagination view example

    Laravel 5 custom pagination view example

    Open Post

    Laravel 5 - How to convert file(image, audio, video) extension using CloudConvert?

    Laravel 5 - How to convert file(image, audio, video) extension using CloudConvert?

    Open Post

    Laravel 5 - create quick backend admin panel tutorial

    Laravel 5 - create quick backend admin panel tutorial

    Open Post

    Laravel 5 - Generate Captcha code and Validation example using BotDetect package

    Laravel 5 - Generate Captcha code and Validation example using BotDetect package

    Open Post