String parser/separation in PHP -


I have data that I want to paste in the text box, it will be in the form of an eG

  Ryu Aiter D78: 21: 87: 13 177/177 1/6 Ryu Chronos D78: 21: 26: 21 182/182 0/6 Ryu Hermes D78: 21: 26: 22 201/2016 0/6 Ryu Hafastos D. 78: 31: 75: 10 136/136 1/2 Rai Crows D 78: 84: 96: 11 170/170 1/6 Raúo Heros D 78: 65: 51: 31 175/175 2/5 Raúl Archnas D 78: 13: 84:11 185/185 0/5  

This type of partition - Base (maximum 16 characters)
Location (staring at d, 12 characters)
Econ / max econ (int / int)
used / total (int / Int)

What I want to do, is making a loop for the text of each line, and then cutting it inside that loop

As long as it I know the idea of ​​separating: the symbol name and the basis have been banned. So if I get ":" first, then take 2 back and choose your position next 12 characters which I know that can be done with loop and if (string [x] = ':'))

But how do I loop through rows? And how can I separate the remaining data in a row?

This is what regular expressions are: try this for:

  $ Lines = explosion ("\ r \ n", $ data); $ Users = array (); Forex currency ($ lines as $ line) {$ matches = array (); $ User = array (); Preg_match ("/ ([^] +) ([?] +) ((?:: [AZ]) (?: [0- 9] + :) {3} [0- 9] +) ([0- 9] ] +) \ / ([0-9] +) ([0- 9] +) \ / ([0- 9] +) / ", $ line, $ matches); List (user '$' ['name'], $ user ['base'], $ user ['location'], $ user ['economy'], $ user ['maxecon'], user $ ['] '], $ User [' total ']) = $ match; $ User [] = $ user; }  

You have an array, which is called users, in which there is a series of accessories with components. Array ([0] = & gt; array ([total] => 6 [used] => 1 [maxen] => 177 [econ] =

  & Gt; 177 [space] => 78: 21: 87: 13 [base] => etar [name] => Ryu) [1] => Hey ([total] => ; 6] [used] = 182 [Eichen] => 182 [space] => D78: 21: 26: 21 [base] => chronos [name] = & amp ;; Ryu) etc., Etc..  

EDIT: I have made several assumptions about the data because you have not given too many details, if you need more help with the expression then tell me.

  line 182: $ name = htmlspecialchars (mysql_real_escape_string ($ _ POST ['name']); line 188: $ tecon = htmlspecialchars (mysql_real_escape_string ($ User ['Econ']));  

You should turn display_errors on because they were simple syntax errors that could easily be debugged.

< / Html>

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -