Hello! There is a line of this type:

"zz" "zz" 0 0 263.57727 1309080332

How can I break it down and write it into the array to make it:

$massiv[0] = zz $massiv[1] = zz $massiv[2] = 0 $massiv[3] = 0 $massiv[4] = 263.57727 $massiv[5] = 1309080332

I found the function: preg_match_all , but I still have not figured out how to use it. You can somehow explain more easily, I learn php not long ago - this is a bit tough =)

    2 answers 2

     $str = '"доброе дело" "хороший день" 0 0 263.57727 1309080332'; preg_match_all('/"([^"]*)"|([\d\.]+)/', $str, $ar); echo '<pre>';print_r($ar);echo '</pre>'; 

    We look, we decide what to do next. ;)

    • Excellent what you need! you can only comment on this section of the code '/"([^""**)"> what these characters are and what they were conceived here - sanstorm
    • Sure you may. [ phpfaq.ru/regexp[[1] [1]: phpfaq.ru/regexp - ling
    • so how can I bring it all through echo separately? if you write echo "$ ar"; nothing comes out. How correctly now to display pieces of lines? - sanstorm
    • Oops! Google loops and multidimensional arrays in php. - ling

    Something like this :)

     $str = "\"zz\" \"zz\" 0 0 263.57727 1309080332"; $massiv = explode(" ", $pizza); print_r($massiv); 
    • The fact is that there are records of this kind “good deed”, “good day” 0 0 263.57727 1309080332 and separate variables $ massiv [0] = “good $ massiv [0] = deed” are obtained. And it is necessary that it was together. - sanstorm
    • @ling, I will promise: those will fly out a notice that there is no Pizza. And will not. and can not be ordered, even for money. Because you declared $str; and I don't care that the pizza didn’t clean the pronin. Who was the last to rule? =))) - knes