'Mom', 'Mark' => 'Dad' ); //Use loop to cycle through array of parents echo "

"; foreach( $parents as $key => $value ) { echo $key . ' ' . $value . '
' . "\n"; } echo "

"; //Reset array reset( $parents ); //Use different loop to approach cycling through array of parents echo "

"; while ( list( $name, $title ) = each( $parents ) ) { echo $name . ' ' . $title . '
' . "\n"; } echo "

"; //Initialize array that will contain sisters $sisters = array(); echo '' . getType($sisters) . ' for sisters created.'; //Add sisters to array $sisters[ 'Sierra' ] = "Sister"; $sisters[ 'Maia' ] = "Sister"; $sisters[ 'Amanda' ] = "Sister"; //Iterate through array of sisters echo '

'; while ( list( $name, $title ) = each ( $sisters ) ) { echo $name . ' ' . $title . '
' . "\n"; } echo '

'; //Combine (union) serpate arrays into one family array //Defines brother array inline $family = $parents + $sisters + ( $brother = array( 'Kyle' => 'Brother' ) ); //Cycle through family array echo '

'; while ( list( $key, $value ) = each ( $family ) ) { echo $key . ' ' . $value . '
' . "\n"; } echo '

'; //Clear the family array from memory unset( $family ); //Create multidimmensional family array $family[ 'parents' ] = $parents; $family[ 'sisters' ] = $sisters; $family[ 'brother' ] = $brother; //Work through multidimmensional array echo '' . "\n"; echo '' . "\n" . '' . "\n" . '' . "\n"; echo '' . "\n" . '' . "\n" . '' . "\n"; while ( $members = each( $family ) ) { while ( list( $name, $title ) = each( $members[ 'value' ] ) ) { echo '' . "\n"; echo ''; echo '' . "\n"; echo '' . "\n"; } } echo "
Family
Name Title
' . $name . '' . $title . '
\n"; echo "
\n "; //Moves array pointer from the end back to the start reset( $family ); //Copies the names from the family array to another array while ( $members = each ( $family ) ) { while ( list( $name, $title ) = each ( $members[ 'value' ] ) ) { $sorted[] = $name; } } //Sort the array by value arsort( $sorted ); //Reference the sorted array by a different name $names = &$sorted; //Work through array sorted by name while ( $name = each( $names ) ) { echo $name[ 'value' ] . "
\n "; } echo "
\n "; //Form for writting new members to the flatfile echo '
' . "\n"; echo "\t" . '' . "\n"; echo "\t \t" . '' . "\n"; echo "\t \t \t" . '' . "\n"; echo "\t \t" . '' . "\n"; echo "\t \t" . '' . "\n"; echo "\t \t \t" . ' ' . "\n"; echo "\t \t \t" . ' ' . "\n"; echo "\t \t \t" . ' ' . "\n"; echo "\t \t \t" . ' ' . "\n"; echo "\t \t" . '' . "\n"; echo "\t" . '
NameTitleLocationAdd
' . ' ' . ' ' . ' ' . '
' . "\n"; echo '
' . "\n"; echo "
\n"; //After the form is submitted create short names for post data form variables $name = $_POST[ 'name' ]; $title = $_POST[ 'title' ]; $location = $_POST[ 'location' ]; //Create variable reference to working directory $DOCUMENT_ROOT = $_SERVER[ 'DOCUMENT_ROOT' ]; //Writes to text file only if the form has been submitted if ( !empty( $name ) || !empty( $title ) || !empty( $location ) ) { //Concatenate a delimiated string to add to the file $string = "\r\n" . $name . ' - ' . $title . ' - ' . $location; //Create file pointer to file that will be written too //Suppress errors @$fp = fopen( "$DOCUMENT_ROOT/data_family.txt", 'ab' ); //Write to file fwrite( $fp, $string ); //Close file fclose( $fp ); //Clear cached POST variables with a redirect to the page of origin header( 'Location: array.php' ); } //Read and copy the contents of this file into an array $filearray = file( "$DOCUMENT_ROOT/data_family.txt" ); //Prepare table to present results returned from file echo '' . "\n"; echo "\t" . '' . "\n"; echo "\t \t" . '' . "\n"; echo "\t" . '' . "\n"; echo "\t" . '' . "\n"; echo "\t \t" . '' . '' . '' . "\n"; echo "\t" . '' . "\n"; //Cycle through file returning delimiated results while ( list( $line, $string ) = each( $filearray ) ) { $copy = explode( " - ", $string ); $name = $copy[0]; $title = $copy[1]; $location = $copy[2]; echo "\t" . '' . "\n"; echo "\t \t" . '' . "\n"; echo "\t" . '' . "\n"; } //End table used to present results echo '
Family
NameTitleLocation
' . $name . '' . $title . '' . $location . '
' . "\n"; echo '
' . "\n"; ?>