I have to serialize an array like PHP does. This is the PHP line of code I have to translate in Swift 4:
serialize(array('p'=>2,'m'=>10,'e'=>20))
I just converted the php array in a Swift struct:
struct codeStructure: Codable {
var p: Int
var m: Int
var e: Int
init() {
p = 2
m = 10
e = 20
}
}
but I need a serialize() function that returns a string like:
a:3:{s:1:"p";i:2;s:1:"m";i:10;s:1:"e";i:20;}
Any hints? Thank you in advance.
Michele