Re: Finding the Middle elements of a String

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 11, 2014, at 11:12 AM, Ken Robinson <kenrbnsn@xxxxxxxxx> wrote:

> What are you really looking to do? If you're looking to get the words out of the string, just explode it into an array and get the elements you want from the array.
> 
> $str  = "apple,cherry,peach,pear";
> $ary = explode(',',$str);
> 
> Ken


THANKS EVERYBODY - SUPER HELPFUL!

Yes I wanted to be able to pull out various elements as listed below - so this works great

<?php
$str  = "apple,cherry,peach,pear";
$ary = explode(',',$str);


// use for various needs...
echo $ary[0].' - ' .$ary[1].' - ' .$ary[2].' - ' .$ary[3].' - ' .$ary[4];

?>






--
Thanks,
Dave - DealTek
dealtek@xxxxxxxxx
[db-14]


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux