Adam Ramadhan Adam Ramadhan - 4 months ago 6x
PHP Question

deleting last array value ? php

1 question type

$transport = array('foot', 'bike', 'car', 'plane');

can i delete the plane ?
is there a way ?

2 question type

$transport = array('', 'bike', 'car', ''); // delate the last line
$transport = array('', 'bike', 'car', 'ferrari'); // dont the last line
$transport = array('ship', 'bike', 'car', 'ferrari'); // dont the last line

is there a easy way to delete the last array " if last array value is empty then delete " if not empty then don't delete ? but not to delete the first array ?

if(empty($transport[count($transport)-1])) {