PHP – How to reindex array key after unset key?
In this post we will give you information about PHP – How to reindex array key after unset key?. Hear we will give you detail about PHP – How to reindex array key after unset key?And how to use it also give you demo for it if it is necessary.
Today, we will learn how to reindex array key from 0 after unset key. we can reassign key using array_values function of php. i will give you simple example for reindex array from 0 after unset key using array_values function. we will reassign keys from numeric like 0 1 2 etc.
Laravel 5 - Class 'Input' not found issue?
In this post we will give you information about Laravel 5 - Class 'Input' not found issue?. Hear we will give you detail about Laravel 5 - Class 'Input' not found issue?And how to use it also give you demo for it if it is necessary.
When i start to work on Laravel 5.2 at that time i fetch this problem "Class 'Input' not found". When i copy my old controller code from laravel 5.1 version that time i found this issue, but i also could use Input insted to Request but i want to use Input as it is. But at last found solution. you have to just use following aliase on your controller.
use IlluminateSupportFacadesInput as Input
Hope this code and post will helped you for implement Laravel 5 - Class 'Input' not found issue?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
Sometime you need to store json to database column at that time it is better if you keep array key as numeric with 0 1 2 etc. so you can easily do json encode and json decode. so you can see in this example how you can make it done for reassign array keys in php.
Example:
<?php
$myArray = [
'0' => [
'name' => 'Paresh',
'email' => 'paresh@gmail.com',
'birthdate' => '01/01/1990',
],
'1' => [
'name' => 'Rakesh',
'email' => 'rakesh@gmail.com',
'birthdate' => '01/01/1990',
],
'2' => [
'name' => 'Mahesh',
'email' => 'mahesh@gmail.com',
'birthdate' => '01/01/1990',
],
'3' => [
'name' => 'Mahesh 2',
'email' => 'mahesh@gmail.com',
'birthdate' => '01/01/1990',
]
];
unset($myArray[2]);
$myArray = array_values($myArray);
print_r($myArray);
?>
Output:
Array
(
[0] => Array
(
[name] => Paresh
[email] => paresh@gmail.com
[birthdate] => 01/01/1990
)
[1] => Array
(
[name] => Rakesh
[email] => rakesh@gmail.com
[birthdate] => 01/01/1990
)
[2] => Array
(
[name] => Mahesh 2
[email] => mahesh@gmail.com
[birthdate] => 01/01/1990
)
)
I hope it can help you…
Hope this code and post will helped you for implement PHP – How to reindex array key after unset key?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs