Posted inphp

php reset array keys – How to Reset Array Keys in PHP?

php reset array keys : using array_values – It returns an indexed array of values from the associative array.

Reset keys of array elements using PHP

The array_values() function returns an array containing all the values of an array. and read this example Php Array Remove Keys Keep Values

php reset array keys
php reset array keys

Example 1: php reset array keys
To reset keys of array elements using PHP, the source code is as follows−

 'tamilblastres',
            '4' => 'hdhub4u',
            '2' => 'tamilmv',
            '7' => 'moviszap'
        ];
  
    $finalOutputArr = array_values($websites);
  
    print_r($finalOutputArr);
  
?>

Result

Array
 (
     [0] => tamilblastres
     [1] => hdhub4u
     [2] => tamilmv
     [3] => moviszap
 )

Example 2: Reset keys of array elements using PHP

 'tamilblastres',
            '4' => 'hdhub4u',
            '2' => 'tamilmv',
            '7' => 'moviszap',
            '6' => '',
            '9' => 'Bolly4u',
            '1' => ''
        ];
  
    $finalOutputArr = array_values(array_filter($websites));
  
    print_r($finalOutputArr);
  
?>

Result

Array
 (
     [0] => tamilblastres
     [1] => hdhub4u
     [2] => tamilmv
     [3] => moviszap
     [4] => Bolly4u
 )

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype