Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Skrypt źle interpretuje plik, Własna struktura pliku i explode()
EdeusEx
post
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 6.04.2008

Ostrzeżenie: (20%)
X----


To mój przykładowy plik *.webcore

Cytat
crtgrp General;
addparam sitetitle value Site;
addparam sitever value 0.1.2;

crtgrp Account;
addparam minidlen value 3;
addparam maxidlen value 4;
addparam minpasslen value 5;
addparam maxpasslen value 5;


I skrypt:
  1. $webCore = file_get_contents($fileWebcore);
  2.  
  3. // -- SET VARS
  4. $Content = array();
  5. $current_group = "";
  6.  
  7. // -- GET LINES
  8. $lines = explode(";", $webCore);
  9. $lines_count = count($lines);
  10.  
  11. // -- WORK WITH FILE
  12. for ($i = 0; $i < $lines_count; $i++) {
  13. $cmd = explode(" ", $lines[$i]);
  14.  
  15. if ($cmd[0] == "crtgrp") {
  16. $Content[$cmd[1]] = $cmd[1];
  17. $debug .= 'Created group '.$Content[$cmd[1]].'<BR/>';
  18. $current_group = $cmd[1];
  19. } else {
  20. if ($cmd[2] == "value") {
  21. $Content[$current_group][$cmd[1]] = $cmd[3];
  22. $debug = $debug.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Created param '.$Content[$current_group][$cmd[1]].' for group '.$current_group.'<BR/>';
  23. }
  24. }
  25. }
  26.  
  27. die($lines_count.'<BR/><BR/>'.$debug);


I output:
Cytat
9

Created group General
Created param S for group General
Created param 0 for group General
Created param 3 for group General
Created param 4 for group General
Created param 5 for group General
Created param 5 for group General


Może mi ktoś powiedzieć, o co chodzi?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 20:24