Php konusunda çok bilgim yok. Php içerisinde javascript çalıştıırılıyorsa, o zaman JSON.stringify() ile yapılabilir.