I'm attempting to pull data in from a text file and sort it into dynamic arrays.
I am having success, except that I can't seem to go beyond the first dynamic array. As it is difficult for me to explain the problem in English, I'll just show you what I'm doing.
Any help here would be hot.
Here is the code:
<p><font face=arial size="2">
<?
$catList=file($DOCUMENT_ROOT."/dataFiles/catList2.txt");
$catCount=count($catList);
$i=0;
while ($i<$catCount) {
if (substr($catList[$i],0,1)<>"-") {
$catHead[]=$catList[$i];
}
$i++;
}
$i=0;
$i2=0;
$HeadCount=count($catHead);
echo "Total entries: $catCount<br>Num. Categories (based on text file formatting): $HeadCount<p>";
while ($i<$catCount) {
while ($i2<$HeadCount) {
$i++;
while (substr($catList[$i],0,1)=="-") {
${$catHead[$i2]}[]=$catList[$i];
$i++;
}
$i2++;
}
$i++;
}
?>
<?
$i=0;
while ($i<$catHeadCount) {
echo $catHead[$i]." - ";
$i++;
}
$i=0;
$i2=0;
while ($i<$HeadCount) {
echo "<b>".str_replace(""," ",$catHead[$i])."</b><br>";
$subCatCount=count(${$catHead[$i]});
while ($i2<$subCatCount) {
$tempVar=substr(${$catHead[$i]}[$i2],1,strlen(${$catHead[$i]}[$i2]));
echo "<font size=1>".str_replace(""," ",$tempVar)."</font>";
$i2++;
if ($i2<$subCatCount) {echo " - ";}
else {echo "<p>";}
}
$i++;
}
?></font></p>
And here is the text file I draw from:
Arts_and_Entertainment
-Bars_and_Clubs
-Booksellers
-Craft_Outlets
-Exotic_Ent.
-Fine_Dining
-Galleries/Museums
-Gambling
-Movie_Theatres
-Theatre/Perf.Arts
-Home_Video_Rental
-Other...
Automotive
-General_Repair
-Sale_and_Service
-Other...
Computers_and_Internet
-Sales_and_Service
-Software_Sales
-Internet_Service(ISP)
-Web_Design/Hosting
-Other...
Education
-College(Jr.and_Univ.)
-Grades_K-12
-Pre_Kindergarten
-Private/Religious
-Special_Education
-Other...
Essential_Services
-Water,Electric,Phone,_Insurance
-Other...
Government
-Federal_Branches
-Local_Government
-Military
-Political
-Other...
Health_and_Wellness
-Dental
-Fitness
-Hospitals
-Medical_Centers
-Mental_Health
-Pharmaceutical
-Therapy
-Veterinary
-Weight_Loss
-Other...
News_and_Media
-Newspapers
-Television
-Radio
-Other...
Organizations
-Civic_Minded
-Educational
-Non_Profit
-Religious
-Other...
Sports_and_Outdoors
-Fishing-Area_Lakes
-Hiking_and_Camping
-Hunting
-Team_Sports
-Other...
Realty
-Business
-Housing
-Property
-Other...
Religious
-Christian
-Other...
Restaurants
-Fast_Food
-Pizza
-Sit-Down_Dining
-Other...
Retail_Outlets
-Clothing_and_Shoes
-General_Merchandise
-Office_Supply
-Other...
Travel
-Car_Rentals
-Travel_Agents
-Other...