stuzer05 / PHP build tree from sql result
0 j'aimes
0 forks
1 fichiers
Dernière activité 2 years ago
| 1 | function buildTree(array $elements, $parentId = 0) { |
| 2 | $branch = array(); |
| 3 | |
| 4 | foreach ($elements as $element) { |
| 5 | if ($element['parent_id'] == $parentId) { |
| 6 | $children = buildTree($elements, $element['id']); |
| 7 | if ($children) { |
| 8 | $element['children'] = $children; |
| 9 | } |
| 10 | $branch[] = $element; |
stuzer05 / PHP create in-memory zip archive
0 j'aimes
0 forks
1 fichiers
Dernière activité 2 years ago
| 1 | $tmp_file = tmpfile(); |
| 2 | $tmp_file_path = stream_get_meta_data($tmp_file)['uri']; |
| 3 | |
| 4 | $zip = new ZipArchive; |
| 5 | $res = $zip->open($tmp_file_path, ZipArchive::CREATE); |
| 6 | |
| 7 | foreach ($ptah_p7s->Signs as $i => $sign) { |
| 8 | $zip->addFromString("signature{$i}.p7s", base64_decode($sign)); |
| 9 | } |
Plus récent
Plus ancien