Jump to content
php.lv forumi

paliidziet ar vienkaarhshu php masiivu!!


justus

Recommended Posts

dots txt fails kuraa sarakstiits kautkas shitam liidziigs

...............................................................................

kaste;vaks;4555.g58f5

456;95;sviests;muca

slon;ugh;8468

................................................................................

..................................

vajag lai katru rindinju ievieto savaa masiivaa (rindinju daudzums var buut neierobezots) un kas atdaliits ar semikolu par atsevisku masiiva veertiibu,

tiku pie shaada risinaajuma:

?php

$f_handle=fopen("fails.txt","r"); 
while($r=fgets($f,4096)){ 
$dati[$i]=explode(";",trim($r)); 
unset($dati[$i][sizeof($dati[$i])]); 
} 
fclose($f); 
?>

Link to comment
Share on other sites

nu tu vareetu pastaastit kaadiem noluukiem tev vajag tik daudz masiivus, bet nu var to txt failu nolasiit un attieciigi sadaliit peec \n un peec tam peec tiem semikoliem

 

$f_handle=fopen("fails.txt","r");

while($r=fgets($f,4096)){

$r.=$r;

}

$n_mas=explode("\\n",$r);

foreach($n_mas as $n)

{

$s_mas=explode(";",$n);

}

Link to comment
Share on other sites

uzstaisiiju skriptu kas no formas nolasa datus

piemeeram shaadus:

vards

uzvards

miilaakaa kraasa

etc.

un saglabaa txt failaa(jo DB nav pieejamas)

katra rindinja ir viens ieraksts, tagad meeginu uztaisiit sho ierakstu atteloshanu noformeetaa veidaa

varbuut katram ierakstam vajag pielikt kautkaadu ID

Link to comment
Share on other sites

×
×
  • Create New...