Insert column value into array using array mapping - php

I have two array i want to add another key in first array by matching keys with second array below are the array that I have
First Array
Array
(
[0] => Array
(
[id] => 5198
[full_name] => Afnan
[username] => eay.d
[is_live] => 1
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/haulysu4upload-image1499828198.jpg
)
[1] => Array
(
[id] => 5213
[full_name] => Nouf
[username] => noufalswailem
[is_live] => 1
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/jlyfgi4fupload-image1502276119.jpg
)
[2] => Array
(
[id] => 5218
[full_name] => Mohammed Bin Abdullah
[username] => almuribadh
[is_live] => 1
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/m3ttx0luupload-image1500789921.jpg
)
[3] => Array
(
[id] => 5225
[full_name] => Shadin Alshobaily
[username] => shash
[is_live] => 1
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/srura4raupload-image1499829155.jpg
)
[4] => Array
(
[id] => 5251
[full_name] => Razan
[username] => ra.m
[is_live] => 1
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/rwfieka6upload-image1499831173.jpg
)
)
Second array that I have
Array
(
[0] => Array
(
[id] => 38395
[request_by] => 2
[request_to] => 5198
)
)
Required Result
Array
(
[0] => Array
(
[id] => 5198
[full_name] => Afnan
[username] => eay.d
[is_live] => 1
[request_sent] => true
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/haulysu4upload-image1499828198.jpg
)
[1] => Array
(
[id] => 5213
[full_name] => Nouf
[username] => noufalswailem
[is_live] => 1
[request_sent] => false
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/jlyfgi4fupload-image1502276119.jpg
)
[2] => Array
(
[id] => 5218
[full_name] => Mohammed Bin Abdullah
[username] => almuribadh
[is_live] => 1
[request_sent] => false
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/m3ttx0luupload-image1500789921.jpg
)
[3] => Array
(
[id] => 5225
[full_name] => Shadin Alshobaily
[username] => shash
[is_live] => 1
[request_sent] => false
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/srura4raupload-image1499829155.jpg
)
[4] => Array
(
[id] => 5251
[full_name] => Razan
[username] => ra.m
[is_live] => 1
[request_sent] => false
[picture] => http://d2flqmogg10inr.cloudfront.net/assets/profile_images/thumbnail1/rwfieka6upload-image1499831173.jpg
)
)
This is just because requested by user 2 has sent friend request to 5198 user and so that's why request_sent is true to this user only and remining will false if friend request not send I want to do this work using buitl in function instead of loops.

Seems very easy, may be i don't uderstand the task
$tmp = array_flip(array_column($arr2, 'request_to'));
foreach($arr1 as &$v) {
$v['request_sent'] = isset($tmp[$v[id]]);
}

Solution without loops (check it online):
<?php
$users = [
['id' => 5198, 'full_name' => 'Afnan', 'username' => 'eay.d', 'is_live' => 1, 'picture' => 'someurl'],
['id' => 5213, 'full_name' => 'Nouf', 'username' => 'noufalswailem', 'is_live' => 1, 'picture' => 'someurl'],
['id' => 5218, 'full_name' => 'Mohammed Bin Abdullah', 'username' => 'almuribadh', 'is_live' => 1, 'picture' => 'someurl'],
['id' => 5225, 'full_name' => 'Shadin Alshobaily', 'username' => 'shash', 'is_live' => 1, 'picture' => 'someurl'],
['id' => 5251, 'full_name' => 'Razan', 'username' => 'ra.m', 'is_live' => 1, 'picture' => 'someurl'],
];
$requests = [
['request_by' => 2, 'request_to' => 5198],
['request_by' => 2, 'request_to' => 5225],
];
array_walk($users, 'setUserRequestStatus', array_column($requests, 'request_to'));
var_dump($users);
function setUserRequestStatus(&$user, $key, $requests_sent_to) {
$user['request_sent'] = in_array($user['id'], $requests_sent_to);
}

Related

merge two array with loop and key name

i have two separate arrays $first_one:
Array
(
[0] => Array
(
[_date] => 2019-10-16
[_number] => 1
[_order] => 1
[name] => jack
[other_ids] => Array
(
[b_id] => 1253
)
)
[1] => Array
(
[_date] => 2020-10-11
[_number] => 2
[_order] => 2
[name] => joey
[other_ids] => Array
(
[b_id] => 1433
)
)
)
and the $second_array:
Array
(
[0] => Array
(
[date] => 2019-10-16
[number] => 1
[order] => 1
[name] => jack
[last_name] => foobar
[other_ids] => Array
(
[b_id] => 1253
)
)
[1] => Array
(
[date] => 2020-10-11
[number] => 2
[order] => 2
[name] => joey
[last_name] => foobar
[other_ids] => Array
(
[b_id] => 1433
)
)
[2] => Array
(
[date] => 2020-10-28
[number] => 3
[order] => 3
[name] => tom
[last_name] => foobar
[other_ids] => Array
(
[b_id] => 1593
)
)
)
they are very similar but they came from different api's and they are different in numbers and also some key names.
so what i'm trying to do is to count the $first_one arrays and if for that many loop through the $second_one (in this example is 2) and if the [_number] [_order] from $first_one was equal (==) to [number] [number] $second_one then take some info (for example the last name) from it and put in a new array.
so is this possible to do?
$arr1 = [ [ '_date' => '2019-10-16','_number' => 1,'_order' => 1,
'name' => 'jack','other_ids' => ['b_id' => 1253]
],
['_date' => 2020-10-11,'_number' => 2,'_order' => 2,
'name' => 'joey','other_ids' => ['b_id' => 1433]
]
];
$arr2 = [ [ 'date' => '2019-10-16','number' => '1','order' => '1',
'name' => 'jack','last_name' => 'foobar','other_ids' => ['b_id' => 1253]
],
[ 'date' => '2019-10-11','number' => '2','order' => '2',
'name' => 'joey','last_name' => 'foobar','other_ids' => ['b_id' => 1433]
],
[ 'date' => '2019-10-28', 'number' => '3', 'order' => '3',
'name' => 'tom', 'last_name' => 'foobar', 'other_ids' => ['b_id' => 1593]
],
];
// first make second array more directly searchable
// make new array with the `number` as the key
foreach( $arr2 as $a){
$arr2new[$a['number']] = $a;
}
foreach ($arr1 as $a) {
if ( array_key_exists($a['_number'], $arr2new) &&
$a['_order'] == $arr2new[$a['_order']]['order'] )
{
$merged[] = ['name'=>$a['name'], 'other_ids' => $a['other_ids']];
}
}
print_r($merged);
RESULT
Array
(
[0] => Array (
[name] => jack
[other_ids] => Array
(
[b_id] => 1253
)
)
[1] => Array (
[name] => joey
[other_ids] => Array
(
[b_id] => 1433
)
)
)

Remove parent array including the children if the children value found empty

I have this array structure.
I'm trying to remove those whole array if I found the [empevalpptwo] empty or null, so if the [empevalpptwo] is empty the whole [4] => Array should be remove.
Right now i'm just trying to get the parent index so I can just remove it by index
Is there any good solution like filtering recursively?
$kra = array_column($ppform_plan->toArray(), 'kra');
$emp_eval_pptwo = array_search('', array_column($kra, 'empevalpptwo'));
//should return 4
Array
(
[4] => Array
(
[id] => 50
[user_id] => 6282
[specific_user_id] => 6281
[eval_cat_id] => 2
[format_cat] => 1
[title] => This istesting
[desc] =>
[weight] => 50
[bsc_weight_group] =>
[bsc_rating] =>
[sequence] =>
[created_at] => 2019-05-22 10:55:23
[updated_at] => 2019-05-22 10:55:23
[kra] => Array
(
[0] => Array
(
[id] => 77
[user_id] => 6282
[bsc_id] => 50
[index] => 0
[kra_title] => ttes lang muna
[kra_desc] =>
[kra_weight] => 25
[sat] => 521
[at] => 4
[ot] => 535
[rating_per_kra] =>
[rating_per_kra_cat] =>
[net_weighting] => 5
[rank] => 1
[remarks] =>
[indicator_text] =>
[created_at] =>
[updated_at] =>
[empevalpptwo] =>
)
[1] => Array
(
[id] => 78
[user_id] => 6282
[bsc_id] => 50
[index] => 1
[kra_title] => talga e2 pa o
[kra_desc] =>
[kra_weight] => 25
[sat] => 5
[at] => 2
[ot] => 4
[rating_per_kra] =>
[rating_per_kra_cat] =>
[net_weighting] => 4
[rank] => 2
[remarks] =>
[indicator_text] =>
[created_at] =>
[updated_at] =>
[empevalpptwo] =>
)
)
)
)
Something akin to:
<?php
$items =
[
1 =>
[
'foo'=>
[
[
'bar' => '',
],
[
'bar' => '',
]
]
],
2 =>
[
'foo'=>
[
[
'bar' => 'baz'
]
]
]
];
foreach ($items as $k => $item)
if(empty(array_filter(array_column($item['foo'], 'bar'))))
unset($items[$k]);
var_export($items);
Output:
array (
2 =>
array (
'foo' =>
array (
0 =>
array (
'bar' => 'baz',
),
),
),
)
You should try this :
$data = array_map('array_filter', $data);
$data = array_filter($data);
UPDATED
and for checking inner values you can use this :
$array = array_filter($array, function($v) { return !empty($v['empevalpptwo']); });
Orginal
Array
(
[con] => Array
(
[address] => Array
(
[city] => ahmedabad
)
[personalinfo] =>
)
)
Result :
Array
(
[con] => Array
(
[address] => Array
(
[city] => ahmedabad
)
)
)

PHP5.3 json_encode is outputting bad json

I am attempting to json_encode an array in php5.3.
json_encode($paperwork_info[0])
The result is bad json. The array is as follows:
[paperwork_guid] => c5bfe512-908d-c513-5a5e-e3a2fbb5548b
[name] => recycle
[sections] => Array
(
[0] => header
[1] => customer
[2] => scope_bullets
[3] => product
[4] => signature
[5] => installer
[6] => order_data
)
[data] => Array
(
[header] => Array
(
[image] => Array
(
[src] => recycle.png
[format] => float:left
)
)
[customer] => Array
(
[f_name] => TEST ONLY
[l_name] => NEIMEIER
[middle_name] => none
[title] => none
[address1] => 28 OEHMAN BLVD
[address2] =>
[address3] =>
[zip] => 14225
[city] => BUFFALO
[state_abbrev] => NY
[email_address] => DALE.NEIMEIER#INSTALLS.COM
[phones] => Array
(
[alt] =>
[cell] =>
[work] =>
[home] => 7165551212
)
)
[scope_bullets] => Array
(
[sku_3001] => Array
(
[bullet_0] => Array
(
[paperwork_bullet_obj_guid] => 2ebefa96-6f6b-069e-e194-245d138b9845
[ordering] => 1
[bullet_text] => This is bullet point #1
[child_level] => 1
[formatting] => Array
(
[0] => Array
(
[start_word] => 2
[num_words] => 0
[tag] => b
[href] =>
)
[1] => Array
(
[start_word] => 2
[num_words] => 1
[tag] => a
[href] => http://www.cnn.com
)
)
)
[bullet_1] => Array
(
[paperwork_bullet_obj_guid] => 734db3f4-01a0-b025-9624-cc52a1845dff
[ordering] => 1
[bullet_text] => Sub-point #1.1
[child_level] => 2
)
[bullet_2] => Array
(
[paperwork_bullet_obj_guid] => ebf5ef02-906e-2005-e499-27eae2edefe9
[ordering] => 1
[bullet_text] => Sub point #1.1.1
[child_level] => 3
)
[bullet_3] => Array
(
[paperwork_bullet_obj_guid] => 447997c1-fd9c-25be-b9bf-39257009fb8b
[ordering] => 1
[bullet_text] => This is bullet point #2
[child_level] => 1
)
[bullet_4] => Array
(
[paperwork_bullet_obj_guid] => 5def2d9c-d322-788c-0afe-d13707004b97
[ordering] => 1
[bullet_text] => Sub point #2.1
[child_level] => 2
)
[bullet_5] => Array
(
[paperwork_bullet_obj_guid] => 84936151-65a3-bcca-951f-b69ff16d34ec
[ordering] => 2
[bullet_text] => Sub point #2.2
[child_level] => 2
)
)
[sku_4405] =>
)
[product] => Array
(
[0] => Array
(
[model] => Paperwork Test abc123
[serial] => 777333
[weight] => 26
[size] =>
[width] =>
[height] => 32
[num_boxes] => 1
[product_name] =>
[sku] =>
[model_number] =>
[part_number] =>
[serial_number] =>
[cat_value] => Best Buy Equipment
[product] =>
[product_type] =>
[product_size] =>
[category] =>
)
)
[signature] => Array
(
[date] => 2016-06-15
[need_customer] => 1
[need_tech] => 1
[need_store] =>
[need_warehouse] =>
)
[installer] => Array
(
[anum] => 45455
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[phone] => (317) 519-0481
[tech_f_name] =>
[tech_l_name] =>
[company_name] => ZICO LLC
[email_address] => ZICOLLC#GMAIL.COM
)
[order_data] => Array
(
[assigned_date] => 2016-06-07 22:24:47-04
[purchased_date] => 2016-06-06
[creation_date] => 2016-06-06
[install_date] => 2016-06-10
[install_time] => 19:00:00
[prescheduled_date] => 1969-12-31
[prom_start_time] => 2016-06-10 08:06:00
[prom_end_time] => 2016-06-10 11:06:00
[client_order_id] => 12365478996325412
[job_num] => 4043269
[campaign_wkord_obj_guid] => a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0
[pos_obj_guid] => 096e38c2-55c3-80cf-0778-23f81f1cf2f6
[inst_obj_guid] => fb91cf85-381c-b740-e063-775151743da2
[client_obj_guid] => 247e893a-3ea4-c544-47b2-f23ff16017c6
[ord_obj_guid] => ae55e034-d7d0-5d13-3dd3-22f99df8ead4
[skus] => Array
(
[0] => Array
(
[job_type_obj_guid] => 8234ca2c-e40e-c48c-befc-7ceac5e9de32
[job_sku] => 3001
[client_sku] =>
[sku_name] => Site Survey
)
[1] => Array
(
[job_type_obj_guid] => a3f60c3b-ad3c-d828-9898-fa200edcd3cd
[job_sku] => 4405
[client_sku] =>
[sku_name] => Home Delivery
)
)
[client_specific_data] =>
)
)
)
The resultant json string is as follows:
{"paperwork_guid":"c5bfe512-908d-c513-5a5e-e3a2fbb5548b","name":"recycle","sections":{"0":"header","1"
:"customer","2":"scope_bullets","3":"product","4":"signature","5":"installer","6":"order_data"},"data"
:{"header":{"image":{"src":"recycle.png","format":"float:left"}},"customer":{"f_name":"TEST ONLY","l_name"
:"NEIMEIER","middle_name":"none","title":"none","address1":"28 OEHMAN BLVD","address2":"","address3"
:null,"zip":"14225","city":"BUFFALO","state_abbrev":"NY","email_address":"DALE.NEIMEIER#INSTALLS.COM"
,"phones":{"alt":"","cell":"","work":"","home":"7165551212"}},"scope_bullets":{"sku_3001":{"bullet_0"
:{"paperwork_bullet_obj_guid":"2ebefa96-6f6b-069e-e194-245d138b9845","ordering":"1","bullet_text":"This
is bullet point #1","child_level":"1","formatting":{"0":{"start_word":"2","num_words":"0","tag":"b"
,"href":""},"1":{"start_word":"2","num_words":"1","tag":"a","href":"http:\/\/www.cnn.com"}}},"bullet_1"
:{"paperwork_bullet_obj_guid":"734db3f4-01a0-b025-9624-cc52a1845dff","ordering":"1","bullet_text":"Sub-point
#1.1","child_level":"2"},"bullet_2":{"paperwork_bullet_obj_guid":"ebf5ef02-906e-2005-e499-27eae2edefe9"
,"ordering":"1","bullet_text":"Sub point #1.1.1","child_level":"3"},"bullet_3":{"paperwork_bullet_obj_guid"
:"447997c1-fd9c-25be-b9bf-39257009fb8b","ordering":"1","bullet_text":"This is bullet point #2","child_level"
:"1"},"bullet_4":{"paperwork_bullet_obj_guid":"5def2d9c-d322-788c-0afe-d13707004b97","ordering":"1","bullet_text"
:"Sub point #2.1","child_level":"2"},"bullet_5":{"paperwork_bullet_obj_guid":"84936151-65a3-bcca-951f-b69ff16d34ec"
,"ordering":"2","bullet_text":"Sub point #2.2","child_level":"2"}},"sku_4405":null},"product":{"0":{"model"
:"Paperwork Test abc123","serial":"777333","weight":"26","size":null,"width":null,"height":"32","num_boxes"
:"1","product_name":null,"sku":null,"model_number":null,"part_number":null,"serial_number":null,"cat_value"
:"Best Buy Equipment","product":null,"product_type":null,"product_size":null,"category":null}},"signature"
:{"date":"2016-06-15","need_customer":true,"need_tech":true,"need_store":false,"need_warehouse":false
},"installer":{"anum":"45455","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","phone":"(317) 519-0481"
,"tech_f_name":null,"tech_l_name":null,"company_name":"ZICO LLC","email_address":"ZICOLLC#GMAIL.COM"
},"order_data":{"assigned_date":"2016-06-07 22:24:47-04","purchased_date":"2016-06-06","creation_date"
:"2016-06-06","install_date":"2016-06-10","install_time":"19:00:00","prescheduled_date":"1969-12-31"
,"prom_start_time":"2016-06-10 08:06:00","prom_end_time":"2016-06-10 11:06:00","client_order_id":"12365478996325412"
,"job_num":"4043269","campaign_wkord_obj_guid":"a9a8cc0b-d7ef-ac0e-df61-dad41c023cb0","pos_obj_guid"
:"096e38c2-55c3-80cf-0778-23f81f1cf2f6","inst_obj_guid":"fb91cf85-381c-b740-e063-775151743da2","client_obj_guid"
:"247e893a-3ea4-c544-47b2-f23ff16017c6","ord_obj_guid":"ae55e034-d7d0-5d13-3dd3-22f99df8ead4","skus"
:{"0":{"job_type_obj_guid":"8234ca2c-e40e-c48c-befc-7ceac5e9de32","job_sku":"3001","client_sku":null
,"sku_name":"Site Survey"},"1":{"job_type_obj_guid":"a3f60c3b-ad3c-d828-9898-fa200edcd3cd","job_sku"
:"4405","client_sku":null,"sku_name":"Home Delivery"}},"client_specific_data":""}}}
It appears as though new line feeds are being inserted randomly throughout the josn string. I am not sure if it is just how firebug is outputting the string, but copying-and-pasting the string into jsonLINT produces errors.
Any help would be appreciated.

access attribute array from transaction object

from the response of braintree. access attribute array from transaction object
which way to access it?
Braintree\Transaction Object (
[_attributes:protected] => Array (
[id] => 3ytqkd
[status] => authorized
[type] => sale
[currencyIsoCode] => USD
[amount] => 100.00
[merchantAccountId] => arvaan
[orderId] =>
[createdAt] => DateTime Object
(
[date] => 2015-12-01 07:15:40
[timezone_type] => 3
[timezone] => UTC
)
[updatedAt] => DateTime Object
(
[date] => 2015-12-01 07:15:40
[timezone_type] => 3
[timezone] => UTC
)
[customer] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[email] =>
[website] =>
[phone] =>
[fax] =>
)
[billing] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[streetAddress] =>
[extendedAddress] =>
[locality] =>
[region] =>
[postalCode] =>
[countryName] =>
[countryCodeAlpha2] =>
[countryCodeAlpha3] =>
[countryCodeNumeric] =>
)
[refundId] =>
[refundIds] => Array
(
)
[refundedTransactionId] =>
[partialSettlementTransactionIds] => Array
(
)
[authorizedTransactionId] =>
[settlementBatchId] =>
[shipping] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[streetAddress] =>
[extendedAddress] =>
[locality] =>
[region] =>
[postalCode] =>
[countryName] =>
[countryCodeAlpha2] =>
[countryCodeAlpha3] =>
[countryCodeNumeric] =>
)
[customFields] =>
[avsErrorResponseCode] =>
[avsPostalCodeResponseCode] => I
[avsStreetAddressResponseCode] => I
[cvvResponseCode] => M
[gatewayRejectionReason] =>
[processorAuthorizationCode] => DHYKZ3
[processorResponseCode] => 1000
[processorResponseText] => Approved
[additionalProcessorResponse] =>
[voiceReferralNumber] =>
[purchaseOrderNumber] =>
[taxAmount] =>
[taxExempt] =>
[creditCard] => Array
(
[token] =>
[bin] => 555555
[last4] => 4444
[cardType] => MasterCard
[expirationMonth] => 12
[expirationYear] => 2017
[customerLocation] => US
[cardholderName] =>
[imageUrl] => https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=sandbox
[prepaid] => Unknown
[healthcare] => Unknown
[debit] => Unknown
[durbinRegulated] => Unknown
[commercial] => Unknown
[payroll] => Unknown
[issuingBank] => Unknown
[countryOfIssuance] => Unknown
[productId] => Unknown
[uniqueNumberIdentifier] =>
[venmoSdk] =>
)
[statusHistory] => Array
(
[0] => Braintree\Transaction\StatusDetails Object
(
[_attributes:protected] => Array
(
[timestamp] => DateTime Object
(
[date] => 2015-12-01 07:15:40
[timezone_type] => 3
[timezone] => UTC
)
[status] => authorized
[amount] => 100.00
[user] => jitendra.arvaan
[transactionSource] => api
)
)
)
[planId] =>
[subscriptionId] =>
[subscription] => Array
(
[billingPeriodEndDate] =>
[billingPeriodStartDate] =>
)
[addOns] => Array
(
)
[discounts] => Array
(
)
[descriptor] => Braintree\Descriptor Object
(
[_attributes:protected] => Array
(
[name] =>
[phone] =>
[url] =>
)
)
[recurring] =>
[channel] =>
[serviceFeeAmount] =>
[escrowStatus] =>
[disbursementDetails] => Braintree\DisbursementDetails Object
(
[_attributes:protected] => Array
(
[disbursementDate] =>
[settlementAmount] =>
[settlementCurrencyIsoCode] =>
[settlementCurrencyExchangeRate] =>
[fundsHeld] =>
[success] =>
)
)
[disputes] => Array
(
)
[paymentInstrumentType] => credit_card
[processorSettlementResponseCode] =>
[processorSettlementResponseText] =>
[threeDSecureInfo] =>
[creditCardDetails] => Braintree\Transaction\CreditCardDetails Object
(
[_attributes:protected] => Array
(
[token] =>
[bin] => 555555
[last4] => 4444
[cardType] => MasterCard
[expirationMonth] => 12
[expirationYear] => 2017
[customerLocation] => US
[cardholderName] =>
[imageUrl] => https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=sandbox
[prepaid] => Unknown
[healthcare] => Unknown
[debit] => Unknown
[durbinRegulated] => Unknown
[commercial] => Unknown
[payroll] => Unknown
[issuingBank] => Unknown
[countryOfIssuance] => Unknown
[productId] => Unknown
[uniqueNumberIdentifier] =>
[venmoSdk] =>
[expirationDate] => 12/2017
[maskedNumber] => 555555******4444
)
)
[customerDetails] => Braintree\Transaction\CustomerDetails Object
(
[_attributes:protected] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[email] =>
[website] =>
[phone] =>
[fax] =>
)
)
[billingDetails] => Braintree\Transaction\AddressDetails Object
(
[_attributes:protected] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[streetAddress] =>
[extendedAddress] =>
[locality] =>
[region] =>
[postalCode] =>
[countryName] =>
[countryCodeAlpha2] =>
[countryCodeAlpha3] =>
[countryCodeNumeric] =>
)
)
[shippingDetails] => Braintree\Transaction\AddressDetails Object
(
[_attributes:protected] => Array
(
[id] =>
[firstName] =>
[lastName] =>
[company] =>
[streetAddress] =>
[extendedAddress] =>
[locality] =>
[region] =>
[postalCode] =>
[countryName] =>
[countryCodeAlpha2] =>
[countryCodeAlpha3] =>
[countryCodeNumeric] =>
)
)
[subscriptionDetails] => Braintree\Transaction\SubscriptionDetails Object
(
[_attributes:protected] => Array
(
[billingPeriodEndDate] =>
[billingPeriodStartDate] =>
)
)
)
)
can access object using magic method
$transaction_id = $result->transaction->__get('id');
you havr to loop through the response you have got using foreach(),
foreach($reas->_attributes as $key => $val) {
echo $key;// will give you the attribute name
is_array($val) ? print_r($val) : echo $val;// will give you the attribute value
}

{Stuck} Populating Data for Template via Docusign php

I am using SOAP API for DocuSign. It is demo account.
So, I have created my code based on sendatemplate.php and I use the templatereference class to create my FieldData and this is the result in array
Array ( [0] => TemplateReference Object ( [TemplateLocation] => Server
[Template] => 2ade4fe1-9b7b-49eb-af2e-xxxxxxxxx [Document] =>
[RoleAssignments] => Array ( [0] => TemplateReferenceRoleAssignment Object (
[RoleName] => Signer1 [RecipientID] => 1 ) ) [FieldData] =>
TemplateReferenceFieldData Object ( [DataValues] => Array ( [0] =>
TemplateReferenceFieldDataDataValue Object ( [TabLabel] => Company [Value]
=> Otto ) ) ) [AdditionalTabs] => [Sequence] => [TemplateAttachments] => ) )
I then use the RequestStatusResponse and this is my result:
RequestStatusResponse Object
(
[RequestStatusResult] => EnvelopeStatus Object
(
[RecipientStatuses] => stdClass Object
(
[RecipientStatus] => Array
(
[0] => RecipientStatus Object
(
[Type] => Signer
[Email] => xxxxxx#yahoo.com
[UserName] => xxxxx
[RoutingOrder] => 1
[Sent] => 2015-12-02T22:56:01.317
[Delivered] => 2015-12-02T22:56:13.567
[Signed] =>
[Declined] =>
[DeclineReason] =>
[Status] => Delivered
[RecipientIPAddress] => xxxxxxxx
[ClientUserId] => 1
[AutoNavigation] =>
[IDCheckInformation] =>
[RecipientAuthenticationStatus] =>
[CustomFields] => stdClass Object
(
)
[TabStatuses] => stdClass Object
(
[TabStatus] => Array
(
[0] => TabStatus Object
(
[TabType] => SignHere
[Status] => Active
[XPosition] => 1333
[YPosition] => 964
[Signed] =>
[TabLabel] => Signature 1
[TabName] => Signature
[TabValue] =>
[DocumentID] =>
[PageNumber] =>
[OriginalValue] =>
[ValidationPattern] =>
[RoleName] =>
[ListValues] =>
[ListSelectedValue] =>
[ScaleValue] =>
[CustomTabType] =>
)
[1] => TabStatus Object
(
[TabType] => Custom
[Status] => Active
[XPosition] => 989
[YPosition] => 916
[Signed] =>
[TabLabel] => Address
[TabName] => Address
[TabValue] =>
[DocumentID] =>
[PageNumber] =>
[OriginalValue] =>
[ValidationPattern] =>
[RoleName] =>
[ListValues] =>
[ListSelectedValue] =>
[ScaleValue] =>
[CustomTabType] =>
)
[2] => TabStatus Object
(
[TabType] => FullName
[Status] => Active
[XPosition] => 989
[YPosition] => 872
[Signed] =>
[TabLabel] => Name 1
[TabName] => Name
[TabValue] =>
[DocumentID] =>
[PageNumber] =>
[OriginalValue] =>
[ValidationPattern] =>
[RoleName] =>
[ListValues] =>
[ListSelectedValue] =>
[ScaleValue] =>
[CustomTabType] =>
)
[3] => TabStatus Object
(
[TabType] => Company
[Status] => Active
[XPosition] => 683
[YPosition] => 252
[Signed] =>
[TabLabel] => Company
[TabName] => Company
[TabValue] =>
[DocumentID] =>
[PageNumber] =>
[OriginalValue] =>
[ValidationPattern] =>
[RoleName] =>
[ListValues] =>
[ListSelectedValue] =>
[ScaleValue] =>
[CustomTabType] =>
)
)
)
[RecipientAttachment] =>
[AccountStatus] =>
[EsignAgreementInformation] =>
[FormData] =>
[RecipientId] =>
)
)
)
I don't see my Company values are populated.
Please help!!!
I am using PHP code to do this.

Categories