Adam Ramadhan Adam Ramadhan - 2 years ago 141
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 ?

Answer Source
if(empty($transport[count($transport)-1])) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download