All pastes #41845 Raw Edit

Something

public php v1 · immutable
#41845 ·published 2006-02-16 16:47 UTC
rendered paste body
<?$file=file("par-armorgrp.txt");//reads the whole file, placing each line as 1 element of the array// $file[0] => line 1// $file[1] => line 2 ...so on$maxlines=count($file); //how many lines we havefor ($i=0;$i < $maxlines;$i++){    //we put the current line on cline    //and remove any line break character    $cline=str_replace("\r","",$file[$i]);    $cline=str_replace("\n","",$cline);        //since the data fields are splited by TABS we jsut explode the line into array    $cline=explode("\t",$cline);    //now we have somthing like    // $cline[0] = 1    // $cline[1] = Short Sword    // $cline[2] = 1    // $cline[3] = 1    // so on..        $item_id=$cline[0]; //if u find spaces being parsed try trim($cline[0])    $name=$cline[1];    $bodypart=$cline[12];    $crystallizable=$cline[10];    $armor_type=$cline[15];    $weight=$cline[8];    $mat=$cline[12];    $crystal_type=$cline[16];    $avoid_modify=$cline[17];    $durability=$cline[7];    $p_def=$cline[18];    $m_def=$cline[19];    $mp_bonus=$cline[20];        $sqlfile .= "SELECT w00t FROM awesome WHERE id = $item_id $name $mat;\r\n";}//output the whole var $sqlfile to a filefile_put_contents ( "armorout.sql", $sqlfile);//FUNCTIONSfunction getMaterialById($materialId){    $mat[1]="oriharukon";    $mat[2]="mithril";    $mat[6]="bronze";    $mat[8]="steel";    $mat[13]="wood";    $mat[14]="bone";    $mat[17]="cloth";    $mat[18]="paper";    $mat[19]="leather";    $mat[23]="crystal";    $mat[47]="adamantaite";    $mat[48]="blood_steel";    $mat[49]="chrysolite";    $mat[50]="damascus";    $mat[51]="fine_steel";    $mat[52]="horn";        if (isset($mat[$materialId]))    {        return $mat[$materialId];    }    else    {        printf("WARNING: Failed to get name for materialId: %d\n",$materialId);        return "unknow";    }}function getBodyPartById($bpId){    $bp[0]="wolf";    //$bp[0]="hatchling";    //$bp[0]="strider";    $bp[7]="rhand";    $bp[8]="lhand";    $bp[14]="lrhand";    if (isset($bp[$bpId]))    {        return $bp[$bpId];    }    else    {        printf("WARNING: Failed to get name for bodyPartId: %d\n",$bpId);        return "unknow";    }}?>