I use explode in my php code to load the strings from a txt file into an array. The strings are loaded into array with no problem, however, the first element has an index 0 but I want it to have an index 1. How do I achieve that?
I appreciate any help cause I've tried so many things and nothing seems to be working and I feel I got stuck.
CodePudding user response:
You can use array_unshift
to insert dummy element then remove it using unset
as follows :
$ex_array = array("PHP","JAVA","C#","Python", "Javascript", "C");
array_unshift($ex_array,"");
unset($ex_array[0]);