Skip to content

A tab-structured tree markup language. Convert outline, unordered lists, organizational charts, etc. into php Array and/or JSON string.

Notifications You must be signed in to change notification settings

page2pagepro/phpTabDownArrayJsonTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

phpTabDownArrayJsonTree

A tab-structured tree markup language. Convert outline, unordered lists, organizational charts, etc. into php Array and/or JSON string.

Inspired by Javascript tabdown: https://github.com/freshdried/tabdown

Credits:

Hierarchical organization Input

<?php

$org_chart = <<<HEREDOC
Constitution
	Legislative Branch
		Congress
			Senate
			House of Representatives
	Executive
		President
			Vice President
			Cabinet
	Judicial
		Supreme Court
		Other Federal Courts
HEREDOC;

@(include_once("phpTabDownArrayJsonTree.php")) 
	OR die ("Failed to include phpTabDownArrayJsonTree.php");

// Convert to Array
$tabDown = tabDown($org_chart);

// Make Json
$json = json_format(json_encode($tabDown));

// Show Output
header('Content-type: application/json');
echo $json;

?>

Hierarchical organization Output

{
	"Constitution\r": {
		"Legislative Branch\r": {
			"Congress\r": {
				"Senate\r": [
					
				],
				"House of Representatives\r": [
					
				]
			}
		},
		"Executive\r": {
			"President\r": {
				"Vice President\r": [
					
				],
				"Cabinet\r": [
					
				]
			}
		},
		"Judicial\r": {
			"Supreme Court\r": [
				
			],
			"Other Federal Courts": [
				
			]
		}
	}
}

The output may be used by JQuery Tree interfaces like this one:

Here's a live Example:

About

A tab-structured tree markup language. Convert outline, unordered lists, organizational charts, etc. into php Array and/or JSON string.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published