Alex Rivera | Logout

deleting last array value ? php

Asked 2010-07-26T19:48:07.450
26

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 ?

Edit
Report

1 Answer

18

for # 1,

$transport=array_slice($transport,0,count($transport)-1)
answered 2010-07-26T20:24:20.843

Your Answer