3v4l.org

run code in 300+ PHP versions simultaneously
<?php $countryCode = '+91'; $phoneNumber = '9028883545'; $callbackData = 'some text here'; $templateName = 'itk_auth_one_tap'; $languageCode = 'en'; $bodyValues = []; $otp = 'LIPSUM'; $headerValues = [$otp]; $buttonValues = [$otp]; // Using your exact code, notice that "buttonValues" doesn't match the expected output $data = [ "countryCode" => $countryCode, "phoneNumber" => $phoneNumber, "callbackData" => $callbackData, "type" => "Template", "template" => [ "name" => $templateName, "languageCode" => $languageCode, "bodyValues" => $bodyValues, "headerValues" => $headerValues, "buttonValues" => $buttonValues // This should be an OBJECT with a property named "0" ] ]; echo json_encode($data, JSON_PRETTY_PRINT); echo "\n\n"; // Let's try to fix it by forcing a stdClass $data = [ "countryCode" => $countryCode, "phoneNumber" => $phoneNumber, "callbackData" => $callbackData, "type" => "Template", "template" => [ "name" => $templateName, "languageCode" => $languageCode, "bodyValues" => $bodyValues, "headerValues" => $headerValues, "buttonValues" => (object) $buttonValues // Cast the array as stdClass ] ]; echo json_encode($data, JSON_PRETTY_PRINT);
Output for git.master_jit, git.master
{ "countryCode": "+91", "phoneNumber": "9028883545", "callbackData": "some text here", "type": "Template", "template": { "name": "itk_auth_one_tap", "languageCode": "en", "bodyValues": [], "headerValues": [ "LIPSUM" ], "buttonValues": [ "LIPSUM" ] } } { "countryCode": "+91", "phoneNumber": "9028883545", "callbackData": "some text here", "type": "Template", "template": { "name": "itk_auth_one_tap", "languageCode": "en", "bodyValues": [], "headerValues": [ "LIPSUM" ], "buttonValues": { "0": "LIPSUM" } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
22.34 ms | 407 KiB | 5 Q