How to separate word in php? -


How to separate words in PHP? In the example I have a variable str = "a1, c1, d1; a2, c2, d2; a3, c3, d3"; I want to isolate the str in the following formats: how to do tt1 = a1, c1, d1, tt2 = a2, c2, d2, tt3 = a3, c3, d3 in php

This attempt But not correct:

  $ str = "a1, c1, d1; a2, c2, d2; a3, c3, d3"; $ StrSplit = Explosion (';', $ str); $ End = array (); ($ I = 0, $ j = 0; $ i & lt; counts ($ strSplit); $ i ++, $ j ++) {$ last [$ j] = $ strSplit for [$ i] . $ StrSplit [$ i + 1]; }    

simply

  $ str = "a1 , C1, D1, A2, C2, D2, A3, C3, D3 "; $ Arr = explosion (';', $ str); Var_dump ($ Arrival);   

... what do you have to give ??

Or do you want parts in the form of variables in your possession, which starts with 'TT'?

  $ str = "a1, c1, d1; a2, c2, d2; a3, c3, d3"; $ Arr = explosion (';', $ str); ($ I = 0; isset ($ arr [$ i]); $ i ++) $ {'tt' ($ I + 1)} = $ arr [$ i]; Print "tt1 = $ tt1 tt2 = $ tt2 tt3 = $ tt3"   

Or possibly as an array of arrays?

  $ str = "a1, c1, d1, a2, c2, d2, a3, c3, d3"; $ Arr = explosion (';', $ str); ($ I = 0; isset ($ arr [$ i]); $ i ++) $ arr [$ i] = Explosion (',', $ arr [$ i]); Var_dump ($ Arrival);   

Or do you want to replace the semi-colon (; ) characters with spaces?

  $ str = "a1, c1, d1, a2, c2, d2, a3, c3, d3"; $ Out = str_replace (';', '', $ str); Print out $;    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -