You creating invalid json by adding apiBlockTicketRequest to output

 $json='apiBlockTicketRequest'.$data;

instead you can do

$json = json_encode(['apiBlockTicketRequest' => $prebook]);
Answer from Robert on Stack Overflow
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ function.json-decode.php
PHP: json_decode - Manual
The introduction of BigInt to modern browsers doesn't help much, when JSON handling functions do not support it. So I am trying to remedy that. My approach is to handle the decoded array before re-encoding it to a string: <?php function fix_large_int(&$value) { if (is_int($value) && $value > 9007199254740991) $value = strval($value); } $json_str = '{"id":[1234567890123456789,12345678901234567890]}'; $json_arr = json_decode($json_str, flags: JSON_BIGINT_AS_STRING | JSON_OBJECT_AS_ARRAY); echo(json_encode($json_arr)); // {"id":[1234567890123456789,"12345678901234567890"]} (BigInt is already converted to a string here) array_walk_recursive($json_arr, 'fix_large_int'); echo(json_encode($json_arr)); // {"id":["1234567890123456789","12345678901234567890"]} ?>
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ 0kvtdskv โ€บ php-array-to-json-example
How do I convert PHP Array to JSON?
To convert a PHP array to JSON data string, you can use the json_encode($value, $flags, $depth) function. The json_encode() function takes a PHP array as input and returns a JSON string representation.
๐ŸŒ
DEV Community
dev.to โ€บ programmingdive โ€บ convert-an-array-to-string-with-php-500g
PHP Array to String: Convert an Array To String with PHP - DEV Community
November 19, 2020 - These two functions only take one array at a time to convert it into a string. ... To convert an array to a string, one of the common ways to do that is to use the json_encode() function which is used to returns the JSON representation of a value.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ 0uwqq41y โ€บ json-to-array-php-example
How do I convert JSON to PHP array?
PHP has two types of arrays: indexed arrays and associative arrays. PHP provides many built-in functions for manipulating arrays, including sorting, searching, checking if an element exists in an array, splitting string to array, converting array to string, converting array to JSON, and getting the length of an array.
๐ŸŒ
PHPpot
phppot.com โ€บ php โ€บ php-array-to-json
PHP Array to JSON String Convert with Online Demo - PHPpot
It removes the user-defined keys from an associative array and applies json_encode to convert it. It is a two-step process. It applies PHP array_values() to read the value array.
๐ŸŒ
Benjamin Crozat
benjamincrozat.com โ€บ home โ€บ blog โ€บ php array to json: the safest way to encode it
PHP array to JSON: the safest way to encode it
March 14, 2026 - With JSON_THROW_ON_ERROR, PHP throws an exception if something goes wrong. Debugging silent failures is for people who like pain. Use exceptions. Readable output matters, especially for debugging. Add the JSON_PRETTY_PRINT flag: $json = json_encode($array, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); Invalid UTF-8: Non-UTF-8 strings ...
Find elsewhere
๐ŸŒ
ProxyScrape
proxyscrape.com โ€บ tools โ€บ php-to-json
PHP Array to JSON Converter - ProxyScrape Tools
Free online tool to convert PHP arrays to JSON format. Convert PHP array syntax to valid JSON objects and arrays with proper formatting. Perfect for PHP developers working with APIs.
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ p9vjxf4s โ€บ php-array-to-string-example
How do I convert an array to a string in PHP?
To convert an array to a string in PHP you can use implode($separator, $array), json_encode($array) or serialize($array) functions.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ php_json.asp
PHP and JSON
The json_decode() function is used to decode a JSON object into a PHP object or an associative array.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-convert-a-string-to-json-object-in-php
How to Convert a String to JSON Object in PHP ? - GeeksforGeeks
July 23, 2025 - PHP provides convenient functions to work with JSON data. ... The json_decode() function is a versatile and commonly used method to convert a JSON-formatted string into a PHP object.
๐ŸŒ
Web4college
web4college.com โ€บ questions โ€บ php โ€บ how-to-convert-object-array-to-string-php.php
How to convert object or array to string in PHP? | json_encode() | serialize()
json_encode() function accepts the array as an argument and converts it into JSON format. Since, It is not possible print the whole array in PHP. That's why we have to convert this array into string with json_encode() function.
๐ŸŒ
PHPpot
phppot.com โ€บ php โ€บ json-to-array-php
Convert JSON to Array in PHP with Online Demo - PHPpot
Creating an online converter for JSON to an array decoding with a single line using PHP json_decode native function.
๐ŸŒ
bishrulhaq
bishrulhaq.com โ€บ home โ€บ posts โ€บ convert php array to json : examples
Convert PHP Array To JSON : Examples | BH
July 1, 2026 - PHP is capable of handling JSON and it has some built-in functions to handle them. json_encode() is used to convert objects, arrays in PHP to JSON format. The PHP json_encode() function returns the string containing a JSON equivalent of the ...
๐ŸŒ
Jsontotable
jsontotable.org โ€บ php-to-json
PHP to JSON Converter - Serialize PHP with json_encode | PHP JSON Serializer | JSON to Table Converter
The converter properly handles nested arrays, multi-dimensional arrays, and mixed data structures, converting them to equivalent JSON representations while maintaining the structure. You can also convert the reverse direction using our JSON to PHP converter. The converter supports PHP arrays (both array() and [] syntax), associative arrays, strings, numbers, booleans (true/false), and null.
๐ŸŒ
Jsontophp
jsontophp.com
Convert JSON Object to PHP Array Online
JSON to PHP array converter online - Convert the given JSON object or Array into beautified PHP array that can be used instantly into your PHP file as a PHP array
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ home โ€บ technologies โ€บ php โ€บ convert php array to string
Convert PHP Array to String
March 2, 2023 - This code explains how to convert an array to a string in PHP using implode function.
๐ŸŒ
websolutionstuff
websolutionstuff.hashnode.dev โ€บ how-to-convert-php-array-to-json-object
How To Convert PHP Array To JSON Object - websolutionstuff
February 9, 2022 - <?php $address = ['city'=>'Mumbai', 'place'=>'Taj Hotel']; $jsonData = json_encode($address); echo $jsonData; ?>