Re: Re: spliting the elements in array

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

 



Stut skrev:
sivasakthi wrote:
Thanks for your response..

Actually i have the collections of strings like,

$not_quite_an_array =
'squid %tu %tl %mt %>A
test %st.%hs %>a %<m %tu %th %Hs %Ss
test1 %tv %tr %Hs.%Ss %mt';


from that i need to split name of each line..

$names = array();
foreach (explode("\n", $not_quite_an_array) as $line)
{
    $line = trim($line);
    if (strlen($line) == 0) continue;
    $names[] = array_shift(explode(' ', $line, 2));
}

-Stut



Or:

$result = preg_match_all("/\s*([^\s]+)(?:\n|.*)/", $not_quite_an_array, $out);
$names = array_pop( $out );


--
/Thunis

I think you ought to know I'm feeling very depressed.
  --The Hitchikers Guide to the Galaxy

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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