go_structure_to_php_array

package module
v0.0.0-...-0f2a621 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 2 Imported by: 0

README

go-structure-to-php-array

Go-structure-to-php-array is a form of encoding a Go data structure into a PHP array.

Use

source := struct {
		A string           `php:"a"`
		B map[string][]int `php:"b"`
		C struct {
			D map[string][]int `php:"d"`
		} `php:"c"`
		E []struct {
			F map[string][]int `php:"f"`
		} `php:"e"`
	}{
		"2",
		map[string][]int{
			"ddd": {
				2, 3,
			},
		},
		struct {
			D map[string][]int `php:"d"`
		}{D: map[string][]int{
			"dssdd": {
				2, 2,
			},
		},
		},
		[]struct {
			F map[string][]int `php:"f"`
		}{
			{F: map[string][]int{"222": {2, 3}}},
		},
	}

target := StructTOPhpArray(source)

Output string structure:

[
   'a' => '2',
   'b' => [
      'ddd' => [
         2,
         3,
      ],
   ],
   'c' => [
      'd' => [
         'dssdd' => [
            2,
            2,
         ],
      ],
   ],
   'e' => [
      [
         'f' => [
            '222' => [
               2,
               3,
            ],
         ],
      ],
   ],
]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StructTOPhpArray

func StructTOPhpArray(v interface{}) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL