php convert array to json object
$myArr = array("apple", "banana", "mango", "jackfruit");
$toJSON = json_encode($myArr);
echo $toJSON;
php convert array to json object
$myArr = array("apple", "banana", "mango", "jackfruit");
$toJSON = json_encode($myArr);
echo $toJSON;
convert json to array in php
<?php
// JSON string
$someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';
// Convert JSON string to Array
$someArray = json_decode($someJSON, true);
print_r($someArray); // Dump all data of the Array
echo $someArray[0]["name"]; // Access Array data
// Convert JSON string to Object
$someObject = json_decode($someJSON);
print_r($someObject); // Dump all data of the Object
echo $someObject[0]->name; // Access Object data
?>
json to array php
<?php
$myArr = '{
"neworder": {
"-newfolder": "NO",
"auth": {
"-extra": "8",
"-login": "login",
"-pass": "pass"
},
"order": {
"-orderno": "111111",
"barcode": "111111",
"sender": {
"company": "Ministry of Internal Affairs",
"person": "I. I. Ivanov",
"phone": "123-45-67",
"town": "Saint-Petersburg",
"address": "Petrovka Str., 38, room 35",
"date": "2021-03-22",
"time_min": "09:00",
"time_max": "14:00"
},
"receiver": {
"company": "Ministry of Internal Affairs",
"person": "Tom Wale",
"phone": "123-45-67",
"zipcode": "125480",
"town": {
"-regioncode": "78",
"-country": "RU",
"#text": "Saint-Petersburg"
},
"address": "Petrovka Str., 38, room 35",
"pvz": "124",
"inn": "1112223335",
"date": "2021-03-22",
"time_min": "09:00",
"time_max": "14:00",
"deliveryPIN": "1234",
"coords": {
"-lat": "55.680327",
"-lon": "37.604456"
}
},
"return": "NO",
"weight": "5.1",
"return_weight": "5.1",
"quantity": "2",
"paytype": "CASH",
"service": "2",
"return_service": "1",
"type": "3",
"return_type": "3",
"courier": "22",
"price": "387.5",
"deliveryprice": {
"-VATrate": "20",
"#text": "150"
},
"inshprice": "387.5",
"receiverpays": "NO",
"discount": "120",
"enclosure": "Kids toys",
"instruction": "Check in the presence of the buyer, sign acceptance certificate",
"department": "Accounting",
"pickup": "NO",
"acceptpartially": "NO",
"costcode": "cc12345",
"items": {
"item": [
{
"-extcode": "abc123",
"-quantity": "1",
"-mass": "0.2",
"-retprice": "37.5",
"-VATrate": "0",
"-barcode": "2345625213125",
"-textArticle": "1",
"-article": "1",
"-volume": "3",
"-origincountry": "AUT",
"-GTD": "321546654",
"-excise": "15.20",
"-suppcompany": "LLC \"Miller and Partners\"",
"-suppphone": "79161234567",
"-suppINN": "1112223334",
"-governmentCode": "11223311",
"#text": "Race car"
},
{
"-extcode": "abc124",
"-quantity": "2",
"-mass": "2",
"-retprice": "100",
"-inshprice": "100",
"-VATrate": "10",
"-barcode": "4645625213138",
"-article": "2",
"-length": "10",
"-width": "20",
"-height": "30",
"-origincountry": "004",
"#text": "Princess castle"
},
{
"-extcode": "abc125",
"-quantity": "3",
"-mass": "0.3",
"-retprice": "50",
"-inshprice": "50",
"-barcode": "2345625213126",
"-itemcode": "44123",
"-article": "3",
"-type": "1",
"#text": "Clay mass"
}
]
},
"packages": {
"package": [
{
"-strbarcode": "ORD0000001",
"-mass": "1",
"-message": ""
},
{
"-strbarcode": "ORD0000002",
"-mass": "2.5",
"-message": "",
"-length": "10",
"-width": "20",
"-height": "30"
}
]
},
"deliveryset": {
"-above_price": "100",
"-return_price": "1000",
"-VATrate": "10",
"below": [
{
"-below_sum": "500",
"-price": "500",
"-self-closing": "true"
},
{
"-below_sum": "2000",
"-price": "300",
"-self-closing": "true"
}
]
},
"overall_volume": "81",
"userid": "123",
"groupid": "456"
}
}
}';
print_r(json_decode($myArr)); ?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us