{"id":33999845,"url":"https://github.com/dottwatson/lonfo","last_synced_at":"2026-05-26T13:05:23.245Z","repository":{"id":56971451,"uuid":"285303408","full_name":"dottwatson/lonfo","owner":"dottwatson","description":"traverse an array by accessing the childrens and parents of a node. You can obtain also the dingle children/value xpath","archived":false,"fork":false,"pushed_at":"2024-10-24T14:46:29.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-14T21:18:23.302Z","etag":null,"topics":["array","children","parent","traversable","xpath"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dottwatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-05T13:56:39.000Z","updated_at":"2024-10-24T14:46:33.000Z","dependencies_parsed_at":"2022-08-21T07:10:19.127Z","dependency_job_id":null,"html_url":"https://github.com/dottwatson/lonfo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dottwatson/lonfo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flonfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flonfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flonfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flonfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dottwatson","download_url":"https://codeload.github.com/dottwatson/lonfo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dottwatson%2Flonfo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33521384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T03:12:49.672Z","status":"ssl_error","status_checked_at":"2026-05-26T03:12:47.976Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","children","parent","traversable","xpath"],"created_at":"2025-12-13T09:08:17.887Z","updated_at":"2026-05-26T13:05:23.221Z","avatar_url":"https://github.com/dottwatson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lonfo\ntraverse an array by accessing the children and parents of a node\n\n## Install\n\nIn your project \n```\ncomposer require dottwatson/lonfo\n```\n\n## Usage\n\n```php\n\n$data = [\n    'bar' =\u003e [0,1,2,3,4,5],\n    'foo' =\u003e [10,20,30,40,50]\n];\n\n\n```\nwith dedicated function\n\n```php\n\n$array = lonfo($data); //returns a Lonfo\\Walker Object\n\n```\nor with instance\n\n```php\n\nuse Lonfo\\Walker;\n\n$array = new Walker($data); //returns a Lonfo\\Walker Object\n\n```\nthen traverse your array\n\n```php\n\n$item = $array-\u003eget('bar'); //returns a Lonfo\\Walker Object\n\n$itemData = $array-\u003eget('bar')-\u003evalue(); //returns  [0,1,2,3,4,5]\n\n//retrieve a value and back to its parent\n\n$item = $array-\u003eget('bar'); //returns a Lonfo\\Walker Object\n$parentNode = $item-\u003eparent(); //returns a Lonfo\\Walker Object of the parent array\n\n//cycle items in array\nwhile($item = $array-\u003enext()){\n   print_r($item-\u003evalue());\n}\n\n//rewind pointer\n$array-\u003erewind();\n\n```\n\naccessing to values\n\n```php\n\n$value = $array-\u003eget('foo')-\u003eget(2);\necho $value-\u003evalue(); //returns 30\n\n$parent = $value-\u003eparent()-\u003evalue(); // returns  [10,20,30,40,50]\n\n\n$result = $array\n    -\u003enthChild(2)   //select child #2\n    -\u003eappend(1000)  //add 1000\n    -\u003eparent()      //return top  of proviouse hthChild\n    -\u003eset('genders',['Male','Female','Unisex']) //add key=\u003evalue\n    -\u003enthChild(1)   //select child #1\n    -\u003eset(6,60)     // add key=\u003evalue\n    -\u003eparent()      // return top of proviouse hthChild\n    -\u003evalue();       //get value\n\n// result = Array\n// (\n//     [bar] =\u003e Array\n//         (\n//             [0] =\u003e 0\n//             [1] =\u003e 1\n//             [2] =\u003e 2\n//             [3] =\u003e 3\n//             [4] =\u003e 4\n//             [5] =\u003e 5\n//             [6] =\u003e 60\n//         )\n\n//     [foo] =\u003e Array\n//         (\n//             [0] =\u003e 10\n//             [1] =\u003e 20\n//             [2] =\u003e 30\n//             [3] =\u003e 40\n//             [4] =\u003e 50\n//             [5] =\u003e 1000\n//         )\n\n//     [genders] =\u003e Array\n//         (\n//             [0] =\u003e Male\n//             [1] =\u003e Female\n//             [2] =\u003e Unisex\n//         )\n\n// )\n\necho $array-\u003eget('bar')-\u003eget(2)-\u003expath(); // returns \"bar/2\"\n\necho $array-\u003exfind('gender/0')-\u003evalue(); //returns \"Male\"\n\n```\n## Available methods on array\n\nHere a list on the available methods on `Lonfo\\Walker`\n\n| Method | Description | Options | Notes |\n|--------|-------------|---------|-------|\n| `get` | Get an item by its key | *string* $key | |\n| `nthChild` | Retrieve a child from its numeric index or a closure. The childs counters starts from 1. If $keyNumber is a Closure, the other extra parameters will be sent to the closure  |  *int \\| Closure* $keyNumber | |\n| `items` | Get indexed items in current array | | |\n| `count` | Returns the array items count | | |\n| `keys` | Returns the array keys | | |\n| `value` |  Return the current array data with all modifications | | |\n| `parent` | Returns the parent node in the array if any | | |\n| `has` | Check if key exists in array | *string* $key | |\n| `prev` | Move internal pointer to the previouse item and returns it if exists | | |\n| `next` | Move internal pointer to the previouse item and returns it if exists | | |\n| `key` | Returns the current item key | | |\n| `rewind` | Reset array internal pointer | | |\n| `first` | Returns the first item in the array if exists | | |\n| `last` | Returns the last item in the array if exists | | |\n| `shift` | Remove the first item in the array if exists and returns it | | |\n| `pop` | Remove the last item in the array if exists and returns it | | |\n| `set` | Set a pair key =\u003e value item in teh array. If exists, will be overwritten | *string* $key, *string* $value | used to add/overwrite items |\n| `append` | Append alle items, passed as arguments, to the array | [$arg1,[$arg2]...] | |\n| `prepend` | Prepends all items, passed as arguments, to the array | [$arg1,[$arg2]...] | |\n| `xpath` | Returns the relative path , included current key  | [*string* $separator = '/'] | |\n| `xfind` | Returns an item or null, based on its xpath relative to current element where search starts | *string* $path,[*string* $separator = '/'] | |\n| `iterable` | Tells if is a valid array (a traversable Walker) | | This is useful for determinate if an end value or array to traverse |\n\n\n## Available methods on Value\n\n\n\nHere a list on the available methods on `Lonfo\\Value`\n\n| Method | Description | Options | Notes |\n|--------|-------------|---------|-------|\n| `key` | Returns the current item key | | |\n| `value` | Returns value | | |\n| `parent` | Returns the parent array | | |\n| `type` | Returns the value type | | |\n| `xpath` | Returns the full data path , included current key  | [*string* $separator = '/'] | |\n| `iterable` | Tells if is a valid array (a traversable Walker) | | This is useful for determinate if an end value or array to traverse |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdottwatson%2Flonfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdottwatson%2Flonfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdottwatson%2Flonfo/lists"}