slice - Stripping unwanted data from an Array in php -
this code builds array:
$size = sizeof($include_quotes); ($i=0; $i<$size; $i++) { $quotes = $globals[$include_quotes[$i]]->quote($method); if (is_array($quotes)) $quotes_array[] = $quotes; } }
if
print_r($quotes_array);
i following:
array ( [0] => array ( [id] => advshipper [methods] => array ( [0] => array ( [id] => 1-0-0 [title] => trade shipping [cost] => 20 [icon] => [shipping_ts] => [quote_i] => 0 ) [1] => array ( [id] => 2-0-0 [title] => 1-2 working days [cost] => 3.2916666666667 [icon] => [shipping_ts] => [quote_i] => 1 ) [2] => array ( [id] => 4-0-0 [title] => 2-3 working days [cost] => 2.4916666666667 [icon] => [shipping_ts] => [quote_i] => 2 ) [3] => array ( [id] => 8-0-0 [title] => click & collect [cost] => 0 [icon] => [shipping_ts] => [quote_i] => 3 ) ) [module] => shipping [tax] => 20 ) )
in circumstances, want data in field 0
passed onto next part of code. however, using
$sliced_quotes_array = array_slice($quotes_array,0,1);
still returns results.
what correct method just:
array ( [0] => array ( [id] => advshipper [methods] => array ( [0] => array ( [id] => 1-0-0 [title] => trade shipping [cost] => 20 [icon] => [shipping_ts] => [quote_i] => 0 )
any appreciated because have tried numerous different ways , no luck yet.
using following still returns same results
$testarray = array(0 => $quotes_array[0]); print_r($testarray);
why not use array constructor , explicitly include need:
array(0 => $quotes_array[0]);
Comments
Post a Comment