Minase Posted September 4, 2008 Share Posted September 4, 2008 hy there i was wondering how to create a php parser for those codes,it seem that whatever i tryed it doesnt work ... (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) i need to create a query for every NPC like : INSERT INTO NPC (`name`, `index`, `country` ..... etc etc) VALUES (1,1,252......etc etc); something like that for every npc Note: some npc can have quest null like this "(quest ))" and it will end just in 2 ")" not in 3. a basic ideea would be awesome thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/ Share on other sites More sharing options...
Mchl Posted September 4, 2008 Share Posted September 4, 2008 I'd remove "(npc" and last ")" , and then I'd try explode() with ") (" as a delimiter for beginning. This shoul give an array like this Array( [0] => "name 1", [1] => "index 1", ... ); Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-634004 Share on other sites More sharing options...
Minase Posted September 5, 2008 Author Share Posted September 5, 2008 thank you for your reply,i did try,but it is problematic,another method ??? thanks Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-634436 Share on other sites More sharing options...
kenrbnsn Posted September 5, 2008 Share Posted September 5, 2008 How were these strings obtained? If you tell us that, perhaps we can get a better idea of how to parse it. Ken Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-634454 Share on other sites More sharing options...
Minase Posted September 5, 2008 Author Share Posted September 5, 2008 this is total another story it is from a game (server side) i want to make now a PHP script for it,but to parse every npc by hand is way to much like (5000 npcs) i dont plan doing them by hands,thats why i asked for a parser, thank you again Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-634846 Share on other sites More sharing options...
discomatt Posted September 5, 2008 Share Posted September 5, 2008 Do you have to do this on the fly, or just once? Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-634873 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 on the fly Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637344 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 is evry line start with '(npc ' or it can be something diferent is one npc in one or multipli lines how you want to insert (mspeed 1600 800) or (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)) in db table Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637360 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 as you can see here i have 2 NPC that must be parsed in 2 querys <!-- FIRST QUERY START (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) FIRST QUERY END --> <!-- SECOND QUERY START (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) SECOND QUERY END --> the thing is that the text is not in just 1 line each after it start with "(npc " it is +3 lines long (all npc are like this) and + 1 empty line the insert should be : name,index..... VALUES 1,1 name,index..... VALUES 2,2 the row name should be take from the "(" start and value after the row name at quest : (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) should be insert into npc (index,name,,,,quest) values (1,1,,, "(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)") hope you did understand thanks Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637392 Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 How about this for starters? <?php $string = "(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)))"; echo $string."<br/><br/>"; $string = substr($string,5,-2); $string = str_replace(array("\r\n", "\n", "\r"),"%lb%",$string); echo $string."<br/><br/>"; $stringExploded = explode("%lb%",$string); var_dump($stringExploded); $stringExploded["quest"] = substr($stringExploded[3],7); unset($stringExploded[3]); foreach ($stringExploded as $key => $line) { $line = substr($line,1,-1); $stringExploded[$key] = explode(") (",$line); } var_dump($stringExploded); ?> Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637407 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 try <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/\n\n/',$test); foreach ($test as $line){ $line = trim($line); // find table name $start = 0; for ($i = 0; $line[$i] !== ' '; $i++); $table = substr($line,1, $i - 1); // remove table name and last ) $lin = substr($line, $i + 1, strlen($line) - $i - 1); $count = 0; $key = array(); $value =array(); $part = ''; for ($i = 0; $i < strlen($lin); $i++){ $chr = $lin[$i]; if ($chr == '(') $count++; if ($chr == ')') $count--; if ($count > 0) { $part .= $chr; } elseif ($part) { $part = explode(' ', trim($part, '('), 2); $key[]= $part[0]; $value[]= $part[1]; $part = ''; } } $key = '(`'.implode('`,`', $key).'`)'; $value = "('".implode("','",$value). "')"; $sql = 'INSERT INTO '. $table.' '. $key. ' VALUES '. $value; echo $sql, "\n";//for testing // do query } ?> Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637529 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 thank you sasa that did the work but it do make everything just in 1 query.. i need to make for every NPC a new query INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`quest`,`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`resist`,`quest`) VALUES ('1','1','252','0','1','1','20','160 240','2','1 2','21','1','10','10','2','1','70','2400','0','0','0 7 7','0 0','0 0','0','1600 800','(2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)','2','2','252','0','3','1','16','160 240','4','2 2','27','2','10','10','4','1','70','2400','0','0','0 8 8','0 0','1 1','0','1600 800','0 0 1 1 1','(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)') that is what it return thanks again Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637541 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 it's mean that 1st split didn't pass OK have you empty line betvin ? Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637554 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 the code is returned as a 4 line output INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`quest`,`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`resist`,`quest`) VALUES ('1','1','252','0','1','1','20','160 240','2','1 2','21','1','10','10','2','1','70','2400','0','0','0 7 7','0 0','0 0','0','1600 800','(2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)','2','2','252','0','3','1','16','160 240','4','2 2','27','2','10','10','4','1','70','2400','0','0','0 8 8','0 0','1 1','0','1600 800','0 0 1 1 1','(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)') //edited the post exactly how you see it return Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637563 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 tryto change $test = preg_split('/\n\n/',$test); to $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637570 Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 I think there's a ( missing between the two records (beginning of the fourth line of query) Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637572 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 Mchl if you look carefull it continue from the third line Sasa,if i replace to your code the page is going to a continue loop,without nothing printing,just loading... it was working till the maximum execution time reach.. now it return a query for every line =/ Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637595 Share on other sites More sharing options...
Mchl Posted September 9, 2008 Share Posted September 9, 2008 VALUES ( '1','1','252','0','1','1','20','160 240','2','1 2','21','1','10','10','2','1','70','2400','0','0','0 7 7','0 0','0 0','0','1600 800','(2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)', '2','2','252','0','3','1','16','160 240','4','2 2','27','2','10','10','4','1','70','2400','0','0','0 8 8','0 0','1 1','0','1600 800','0 0 1 1 1','(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)' ) That's a quote from previous post. I believe these are two records, and each should be enclosed in (). Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637606 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 yes this is correct,sorry for misunderstooding you this thing is harder than i expected //edit here is what it return INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`) VALUES ('1','1','252','0','1','1','20','160 240','2','1 2') INSERT INTO str (``) VALUES ('') INSERT INTO attack (``) VALUES ('') INSERT INTO quest (`2`,`3`,`54`,`8001`) VALUES ('1 901 1','1 902 1','1 1025 1','1 933 1') Fatal error: Maximum execution time of 60 seconds exceeded in LOCATION Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637608 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 can you post exactly string for input i try code for input (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) end it output is INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`quest`) VALUES ('1','1','252','0','1','1','20','160 240','2','1 2','21','1','10','10','2','1','70','2400','0','0','0 7 7','0 0','0 0','0','1600 800','(2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1)') INSERT INTO npc (`name`,`index`,`country`,`race`,`level`,`ai`,`range`,`sight`,`exp`,`itemgroup`,`str`,`hth`,`int`,`wis`,`dex`,`hp`,`mp`,`aspeed`,`hit`,`dodge`,`attack`,`magic`,`defense`,`absorb`,`mspeed`,`resist`,`quest`) VALUES ('2','2','252','0','3','1','16','160 240','4','2 2','27','2','10','10','4','1','70','2400','0','0','0 8 8','0 0','1 1','0','1600 800','0 0 1 1 1','(2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)') time is 0.037781 s Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637613 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 i did use exactly same input as yours Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637620 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 sorry for double post,but i could not edit the last one here is the current code <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); foreach ($test as $line){ $line = trim($line); // find table name $start = 0; for ($i = 0; $line[$i] !== ' '; $i++); $table = substr($line,1, $i - 1); // remove table name and last ) $lin = substr($line, $i + 1, strlen($line) - $i - 1); $count = 0; $key = array(); $value =array(); $part = ''; for ($i = 0; $i < strlen($lin); $i++){ $chr = $lin[$i]; if ($chr == '(') $count++; if ($chr == ')') $count--; if ($count > 0) { $part .= $chr; } elseif ($part) { $part = explode(' ', trim($part, '('), 2); $key[]= $part[0]; $value[]= $part[1]; $part = ''; } } $key = '(`'.implode('`,`', $key).'`)'; $value = "('".implode("','",$value). "')"; $sql = 'INSERT INTO '. $table.' '. $key. ' VALUES '. $value; echo $sql, "\n";//for testing // do query } ?> it do enter into maximum execution time and return a query for every line. Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637648 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 it's somethin wrong with 1st split can you try just first part of code <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); print_r($test); ?> and post output is it Array ( [0] => (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) [1] => (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) ) Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637703 Share on other sites More sharing options...
Minase Posted September 9, 2008 Author Share Posted September 9, 2008 here it is the problem Array ( [0] => (npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) [1] => (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) [2] => (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) [3] => (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) [4] => [5] => (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) [6] => (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) [7] => (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) [8] => (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1))) ) here it to put every new line to array Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637729 Share on other sites More sharing options...
sasa Posted September 9, 2008 Share Posted September 9, 2008 try <?php $test = '(npc (name 1) (index 1) (country 252) (race 0) (level 1) (ai 1) (range 20) (sight 160 240) (exp 2) (itemgroup 1 2) (str 21) (hth 1) (int 10) (wis 10) (dex 2) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 7 7) (magic 0 0) (defense 0 0) (absorb 0) (mspeed 1600 800) (quest (2 1 901 1) (3 1 902 1) (54 1 1025 1) (8001 1 933 1))) (npc (name 2) (index 2) (country 252) (race 0) (level 3) (ai 1) (range 16) (sight 160 240) (exp 4) (itemgroup 2 2) (str 27) (hth 2) (int 10) (wis 10) (dex 4) (hp 1) (mp 70) (aspeed 2400) (hit 0) (dodge 0) (attack 0 8 (magic 0 0) (defense 1 1) (absorb 0) (mspeed 1600 800) (resist 0 0 1 1 1) (quest (2 1 901 1) (3 1 902 1) (55 1 1026 1) (8001 1 933 1)))'; $test = preg_split('/(\n|\r|\n\r){2,2}/',$test); $test = array_chunk($test,5); foreach ($test as $k => $v) $test[$k] = implode($v); print_r($test); ?> is it OK now Quote Link to comment https://forums.phpfreaks.com/topic/122780-solved-php-parser/#findComment-637739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.