একটি অ্যারের উপাদান সরাতে এবং অ্যারেটিকে পুনরায় সূচী করতে, কোডটি নিম্নরূপ-
উদাহরণ
<?php $arr = array( " John ", "Jacob ", " Tom ", " Tim "); echo "Array with leading and trailing whitespaces...\n"; foreach( $arr as $value ) { echo "Value = $value \n"; } echo "\nComma separated list...\n"; print_r(implode(', ', $arr)); $result = array_map('trim', $arr); echo "\nUpdated Array...\n"; foreach( $result as $value ) { echo "Value = $value \n"; } unset($result[1]); echo "\nUpdated Array...Re-indexed\n"; $result2 = array_values($result); foreach( $result2 as $value ) { echo "Value = $value \n"; } ?>
আউটপুট
এটি নিম্নলিখিত আউটপুট-
তৈরি করবেArray with leading and trailing whitespaces... Value = John Value = Jacob Value = Tom Value = Tim Comma separated list... John , Jacob , Tom , Tim Updated Array... Value = John Value = Jacob Value = Tom Value = Tim Updated Array...Re-indexed Value = John Value = Tom Value = Tim