= $parentheses_end ) {
// Whoops! parentheses missing...
// echo( "Missing parentheses on line: " . $i . "\n\n" . $line_str . "
");
return false;
} else {
// Grab ID
$id_str = substr( $line_str, $parentheses_start+1, ( $parentheses_end - $parentheses_start - 1 ) );
if ( $id_str == '' ) {
// echo( "Missing 'Unique ID Number' on line: " . $i . "\n\n" . $line_str );
return false;
} else {
$id_number = intVal( $id_str );
if ( gettype( $id_number ) === 'integer' ) {
// echo( "'" . $id_str . "' - '" . $id_number . "'
" );
// So far so good... Now get rid of trailing spaces.
$name_str = substr( $line_str, 0, $parentheses_start );
while ( substr( $name_str, strlen( $name_str )-1, strlen( $name_str ) ) == ' ' ) {
$name_str = substr( $name_str, 0, strlen( $name_str ) - 1 );
}
// Count beginning spaces or characters...
$space_count = 0;
while ( substr( $name_str, 0, 1 ) == ' ' || substr( $name_str, 0, 1 ) == chr( 160 ) ) {
$name_str = substr( $name_str, 1, strlen( $name_str ) - 1 );
$space_count++;
}
if ( $name_str != '' ) {
// Okay, we've got all the parts...
$item_arr = Array( $id_number, clean_post_text( $name_str ), $space_count );
array_push( $valid_arr, $item_arr );
// echo( "ID = ".$id_number.", NAME = '".$name_str."', DEPTH = ".$space_count."
" );
} else {
// echo( "Missing 'Category Name' on line: " . $i . "\n\n" . $line_str );
return false;
}
} else {
// echo( "'Unique ID' (" . $id_str . ") is not a number on line: " . $i . "\n\n" . $line_str );
return false;
}
}
}
}
}
// echo( "Success! " . count($valid_arr) . " categories validated!" );
return $valid_arr;
}
}
?>