I have a simple code and when I print_r it, this one is the output:
Array
(
[0] => App\Entities\EibPerson Object
(
[personId:App\Entities\EibPerson:private] => 10025
[createdBy:App\Entities\EibPerson:private] => 1
[createdOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:33:59.000000
[timezone_type] => 1
[timezone] => +03:00
)
[modifiedBy:App\Entities\EibPerson:private] => 1
[modifiedOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:33:59.000000
[timezone_type] => 1
[timezone] => +03:00
)
[recordVersion:App\Entities\EibPerson:private] => 1
[activeFlag:App\Entities\EibPerson:private] => 1
[firstName:App\Entities\EibPerson:private] => test person name
[middleName:App\Entities\EibPerson:private] => test middle
[lastName:App\Entities\EibPerson:private] => test last name
[displayName:App\Entities\EibPerson:private] => sorxrob
[dateOfBirth:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 1992-10-01 03:00:00.000000
[timezone_type] => 1
[timezone] => +03:00
)
[landlineNumber:App\Entities\EibPerson:private] => 2312321313131
[mobileNumber:App\Entities\EibPerson:private] => 876543454
[emailAddress:App\Entities\EibPerson:private] => sorianorobertc#gmail.com
[heightInches:App\Entities\EibPerson:private] => 6
[inseamLengthInches:App\Entities\EibPerson:private] => 6
[weightInKgs:App\Entities\EibPerson:private] => 80.00
[profilePictureUrl:App\Entities\EibPerson:private] =>
[sourceDesc:App\Entities\EibPerson:private] => testsourceDesc
[remarks:App\Entities\EibPerson:private] => test remarks test
[memberId:App\Entities\EibPerson:private] =>
[externalReferenceId:App\Entities\EibPerson:private] =>
[genderEnumRid:App\Entities\EibPerson:private] =>
[address:App\Entities\EibPerson:private] =>
[tshirtSizeEnumRid:App\Entities\EibPerson:private] =>
[bloodGroupEnumRid:App\Entities\EibPerson:private] =>
[managingBranch:App\Entities\EibPerson:private] =>
[foodPreferenceEnumRid:App\Entities\EibPerson:private] =>
[sourceEnumRid:App\Entities\EibPerson:private] =>
[sourceDetailRid:App\Entities\EibPerson:private] =>
[externalSourceSysEnumRid:App\Entities\EibPerson:private] =>
)
[1] => App\Entities\EibPerson Object
(
[personId:App\Entities\EibPerson:private] => 10026
[createdBy:App\Entities\EibPerson:private] => 1
[createdOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:36:03.000000
[timezone_type] => 1
[timezone] => +03:00
)
[modifiedBy:App\Entities\EibPerson:private] => 1
[modifiedOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:36:03.000000
[timezone_type] => 1
[timezone] => +03:00
)
[recordVersion:App\Entities\EibPerson:private] => 1
[activeFlag:App\Entities\EibPerson:private] => 1
[firstName:App\Entities\EibPerson:private] => test person name
[middleName:App\Entities\EibPerson:private] => test middle
[lastName:App\Entities\EibPerson:private] => test last name
[displayName:App\Entities\EibPerson:private] => sorxrob
[dateOfBirth:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 1992-10-01 03:00:00.000000
[timezone_type] => 1
[timezone] => +03:00
)
[landlineNumber:App\Entities\EibPerson:private] => 2312321313131
[mobileNumber:App\Entities\EibPerson:private] => 876543454
[emailAddress:App\Entities\EibPerson:private] => sorianorobertc#gmail.com
[heightInches:App\Entities\EibPerson:private] => 6
[inseamLengthInches:App\Entities\EibPerson:private] => 6
[weightInKgs:App\Entities\EibPerson:private] => 80.00
[profilePictureUrl:App\Entities\EibPerson:private] =>
[sourceDesc:App\Entities\EibPerson:private] => testsourceDesc
[remarks:App\Entities\EibPerson:private] => test remarks test
[memberId:App\Entities\EibPerson:private] =>
[externalReferenceId:App\Entities\EibPerson:private] =>
[genderEnumRid:App\Entities\EibPerson:private] =>
[address:App\Entities\EibPerson:private] =>
[tshirtSizeEnumRid:App\Entities\EibPerson:private] =>
[bloodGroupEnumRid:App\Entities\EibPerson:private] =>
[managingBranch:App\Entities\EibPerson:private] =>
[foodPreferenceEnumRid:App\Entities\EibPerson:private] =>
[sourceEnumRid:App\Entities\EibPerson:private] =>
[sourceDetailRid:App\Entities\EibPerson:private] =>
[externalSourceSysEnumRid:App\Entities\EibPerson:private] =>
)
[2] => App\Entities\EibPerson Object
(
[personId:App\Entities\EibPerson:private] => 10027
[createdBy:App\Entities\EibPerson:private] => 1
[createdOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:37:25.000000
[timezone_type] => 1
[timezone] => +03:00
)
[modifiedBy:App\Entities\EibPerson:private] => 1
[modifiedOn:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 2016-12-06 08:37:25.000000
[timezone_type] => 1
[timezone] => +03:00
)
[recordVersion:App\Entities\EibPerson:private] => 1
[activeFlag:App\Entities\EibPerson:private] => 1
[firstName:App\Entities\EibPerson:private] => test person name
[middleName:App\Entities\EibPerson:private] => test middle
[lastName:App\Entities\EibPerson:private] => test last name
[displayName:App\Entities\EibPerson:private] => sorxrob
[dateOfBirth:App\Entities\EibPerson:private] => DateTime Object
(
[date] => 1992-10-01 03:00:00.000000
[timezone_type] => 1
[timezone] => +03:00
)
[landlineNumber:App\Entities\EibPerson:private] => 2312321313131
[mobileNumber:App\Entities\EibPerson:private] => 876543454
[emailAddress:App\Entities\EibPerson:private] => sorianorobertc#gmail.com
[heightInches:App\Entities\EibPerson:private] => 6
[inseamLengthInches:App\Entities\EibPerson:private] => 6
[weightInKgs:App\Entities\EibPerson:private] => 80.00
[profilePictureUrl:App\Entities\EibPerson:private] =>
[sourceDesc:App\Entities\EibPerson:private] => testsourceDesc
[remarks:App\Entities\EibPerson:private] => test remarks test
[memberId:App\Entities\EibPerson:private] =>
[externalReferenceId:App\Entities\EibPerson:private] =>
[genderEnumRid:App\Entities\EibPerson:private] =>
[address:App\Entities\EibPerson:private] =>
[tshirtSizeEnumRid:App\Entities\EibPerson:private] =>
[bloodGroupEnumRid:App\Entities\EibPerson:private] =>
[managingBranch:App\Entities\EibPerson:private] =>
[foodPreferenceEnumRid:App\Entities\EibPerson:private] =>
[sourceEnumRid:App\Entities\EibPerson:private] =>
[sourceDetailRid:App\Entities\EibPerson:private] =>
[externalSourceSysEnumRid:App\Entities\EibPerson:private] =>
)
)
My code:
$person = $this->em->getRepository('App\Entities\EibPerson')->findAll();
print_r($person);
What I actually want is to only get this:
How can I possibly do that? Because I want to json_encode the array but im getting an empty json..
Debug with max depth
You could use maxDepth variable of Doctrine Dump.
You can use \Doctrine\Common\Util\Debug::dump($variable, $depth); it displays doctrine output without the proxy information.
More readable output
If you are using symfony 2.6 or more, I strongly advice you to use dump() instead of var_dump() or print_r().
Dump shows a well formated and colored output, and you can expand/hide rows.
Finally... to json
To export object(s) to json, I advice you to use serializer and normalizer services, you can find here in the documentation
Related
I am working on something in Wordpress and need to parse an array of objects and get some specific property information values.
I believe I am having issues be cause the property name has colons in it:
EX: id:DLM_Download_Version:private
The arrays name is $versions. This is the value of the array when i use print_r:
(
[0] => DLM_Download_Version Object
(
[id:DLM_Download_Version:private] => 208
[author:DLM_Download_Version:private] => 1
[download_id:DLM_Download_Version:private] => 196
[menu_order:DLM_Download_Version:private] => 0
[latest:DLM_Download_Version:private] =>
[date:DLM_Download_Version:private] => DateTime Object
(
[date] => 2022-03-22 12:48:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[version:DLM_Download_Version:private] => 3
[download_count:DLM_Download_Version:private] => 0
[filesize:DLM_Download_Version:private] => 2966739
[md5:DLM_Download_Version:private] =>
[sha1:DLM_Download_Version:private] =>
[sha256:DLM_Download_Version:private] =>
[crc32b:DLM_Download_Version:private] =>
[mirrors:DLM_Download_Version:private] => Array
(
[0] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/STS-SENTIMENT-REPORT-3-21-22.pdf
)
[url:DLM_Download_Version:private] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/STS-SENTIMENT-REPORT-3-21-22.pdf
[filename:DLM_Download_Version:private] => STS-SENTIMENT-REPORT-3-21-22.pdf
[filetype:DLM_Download_Version:private] => pdf
)
[1] => DLM_Download_Version Object
(
[id:DLM_Download_Version:private] => 200
[author:DLM_Download_Version:private] => 1
[download_id:DLM_Download_Version:private] => 196
[menu_order:DLM_Download_Version:private] => 1
[latest:DLM_Download_Version:private] =>
[date:DLM_Download_Version:private] => DateTime Object
(
[date] => 2022-03-22 12:37:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[version:DLM_Download_Version:private] => 2
[download_count:DLM_Download_Version:private] => 2
[filesize:DLM_Download_Version:private] => 3059630
[md5:DLM_Download_Version:private] =>
[sha1:DLM_Download_Version:private] =>
[sha256:DLM_Download_Version:private] =>
[crc32b:DLM_Download_Version:private] =>
[mirrors:DLM_Download_Version:private] => Array
(
[0] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/sts-weekly-sentiment-report-3-14-22.pdf
)
[url:DLM_Download_Version:private] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/sts-weekly-sentiment-report-3-14-22.pdf
[filename:DLM_Download_Version:private] => sts-weekly-sentiment-report-3-14-22.pdf
[filetype:DLM_Download_Version:private] => pdf
)
[2] => DLM_Download_Version Object
(
[id:DLM_Download_Version:private] => 197
[author:DLM_Download_Version:private] => 1
[download_id:DLM_Download_Version:private] => 196
[menu_order:DLM_Download_Version:private] => 2
[latest:DLM_Download_Version:private] =>
[date:DLM_Download_Version:private] => DateTime Object
(
[date] => 2022-03-22 12:35:00.000000
[timezone_type] => 3
[timezone] => UTC
)
[version:DLM_Download_Version:private] => 1
[download_count:DLM_Download_Version:private] => 0
[filesize:DLM_Download_Version:private] => 2648776
[md5:DLM_Download_Version:private] =>
[sha1:DLM_Download_Version:private] =>
[sha256:DLM_Download_Version:private] =>
[crc32b:DLM_Download_Version:private] =>
[mirrors:DLM_Download_Version:private] => Array
(
[0] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/STS-WEEKLY-SENTIMENT-REPORT-3-8-22.pdf
)
[url:DLM_Download_Version:private] => https://wordpress-360386-2306631.cloudwaysapps.com/wp-content/uploads/dlm_uploads/2022/03/STS-WEEKLY-SENTIMENT-REPORT-3-8-22.pdf
[filename:DLM_Download_Version:private] => STS-WEEKLY-SENTIMENT-REPORT-3-8-22.pdf
[filetype:DLM_Download_Version:private] => pdf
)
)
How can I get just the values of id:DLM_Download_Version:private?
I have tried a foreach loop:
foreach ($versions as $version){
echo $version->{'id:DLM_Download_Version:private'}
}
which just outputs nothing.
Hi Guys :) I have something like that:
Array
(
[0] => Ideneal\OpenLoad\Entity\RemoteUploadStatus Object
(
[remoteUpload:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => Ideneal\OpenLoad\Entity\RemoteUpload Object
(
[id:Ideneal\OpenLoad\Entity\RemoteUpload:private] => xxxx
[folderId:Ideneal\OpenLoad\Entity\RemoteUpload:private] => xxxx
)
[remoteUrl:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => https://openload.co/embed/xxxxx
[status:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => finished
[bytesLoaded:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] =>
[bytesTotal:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] =>
[addedDate:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => DateTime Object
(
[date] => 2017-07-21 10:53:55.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
[lastUpdateDate:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => DateTime Object
(
[date] => 2017-07-21 10:53:55.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
)
[fileId:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => xxxx
[url:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private] => https://openload.co/f/xxxx <------------ Here is what I want to write to a variable
)
)
(At the end of the code is a comment)
How to do that ?
I tried something like that: print_r($myarray[0][url:Ideneal\OpenLoad\Entity\RemoteUploadStatus:private])
and nothing.
Try to use RemoteUploadStatus object methods:
$myarray[0]->getUrl();
Ref.: https://github.com/Ideneal/OpenLoad/blob/master/src/Entity/RemoteUploadStatus.php
I am trying to get the recurrence of an event with the Google Calendar API in PHP, and it doesn't show me the recurrence.
The following code is the code I'm using:
$params = array(
'orderBy' => 'startTime',
'singleEvents' => true,
'timeMin' => date('c'),
);
$listarEventos = $service->events->listEvents($calendar_id, $params);
foreach ($listarEventos->getItems() as $i){
echo "<pre>";
echo $i->recurrence;
print_r($i);
echo "</pre>";
echo "<br>";
}
And I am obtaining this type of objects:
Google_Service_Calendar_Event Object
(
[collection_key:protected] => recurrence
[internal_gapi_mappings:protected] => Array
(
)
[anyoneCanAddSelf] =>
[attendeesType:protected] => Google_Service_Calendar_EventAttendee
[attendeesDataType:protected] => array
[attendeesOmitted] =>
[colorId] =>
[created] => 2015-06-01T07:34:46.000Z
[creatorType:protected] => Google_Service_Calendar_EventCreator
[creatorDataType:protected] =>
[description] =>
[endType:protected] => Google_Service_Calendar_EventDateTime
[endDataType:protected] =>
[endTimeUnspecified] =>
[etag] => "286628817348xxxx"
[extendedPropertiesType:protected] => Google_Service_Calendar_EventExtendedProperties
[extendedPropertiesDataType:protected] =>
[gadgetType:protected] => Google_Service_Calendar_EventGadget
[gadgetDataType:protected] =>
[guestsCanInviteOthers] =>
[guestsCanModify] =>
[guestsCanSeeOtherGuests] =>
[hangoutLink] =>
[htmlLink] => https://www.google.com/calendar/event?eid=czlqcW9uNmg1aGV0cTBwYXRrcnIxc2dqc3MgcHJ1ZWJhY2FsZW5kYXJpbxxxxxt
[iCalUID] => s9jqon6h5hetq0patkrr1sgjss#google.com
[id] => s9jqon6h5hetq0patkrr1sxxxxx
[kind] => calendar#event
[location] => Gra
[locked] =>
[organizerType:protected] => Google_Service_Calendar_EventOrganizer
[organizerDataType:protected] =>
[originalStartTimeType:protected] => Google_Service_Calendar_EventDateTime
[originalStartTimeDataType:protected] =>
[privateCopy] =>
[recurrence] =>
[recurringEventId] =>
[remindersType:protected] => Google_Service_Calendar_EventReminders
[remindersDataType:protected] =>
[sequence] => 0
[sourceType:protected] => Google_Service_Calendar_EventSource
[sourceDataType:protected] =>
[startType:protected] => Google_Service_Calendar_EventDateTime
[startDataType:protected] =>
[status] => confirmed
[summary] => Prueba recurrencia
[transparency] =>
[updated] => 2015-06-01T07:34:46.742Z
[visibility] =>
[modelData:protected] => Array
(
[creator] => Array
(
[email] => xxxx#gmail.com
[displayName] => Prueba Calendario
[self] => 1
)
[organizer] => Array
(
[email] => xxxxx#gmail.com
[displayName] => Prueba Calendario
[self] => 1
)
[start] => Array
(
[dateTime] => 2015-06-19T03:01:00+02:00
[timeZone] => Europe/Madrid
)
[end] => Array
(
[dateTime] => 2015-06-19T09:03:00+02:00
[timeZone] => Europe/Madrid
)
[reminders] => Array
(
[useDefault] => 1
)
)
[processed:protected] => Array
(
)
)
I have to say that I store the recurrence with the following code:
$event->setRecurrence(array('RRULE:FREQ='.$FREQ.';INTERVAL='.$INTERVAL));
And I have proved that the event is recurrent, so I donĀ“t know why I can't get the recurrence.
Thanks a lot!
You won't get recurrence if you're using 'singleEvents' => true.
Documentation (https://developers.google.com/google-apps/calendar/v3/reference/events/list) says:
singleEvents boolean Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
I have solved the question. You won't get the recurrence if you doesn't get the event with something like this:
$event = $service->events->get('primary', "recurringEventId");
Once you have $event, you can use:
$preevent->recurrence[0]
Thanks to Xeron for the answer.
PHP - Access MSSQL datetime column from the returned array
Array
(
[0] => Array
(
[CallId] => 45
[CallLoginId] => 1
[CustomerId] => 140
[CallOptionId] => 2
[CallTypeId] => 2
[CallStatusId] => 1
[CallDateTime] => DateTime Object
(
[date] => 2012-06-28 00:00:00
[timezone_type] => 3
[timezone] => Asia/Kolkata
)
[ContactNo] => 45151551115
[ContactPerson] => Contact Person name
[ProductId] => 1
[ProdCompanyId] => 1
[ProdCategoryId] => 1
[ModelNo] => 451212151
[ProdUnderId] => 1
[Problem] => Simple Problem Details
[Remarks] => Remarks
[Accessories] => Accessories
[CallCaseId] =>
[CallCaseDate] =>
[ServiceCharge] => 0
[CourierName] =>
[DocketNo] =>
[CompanyId] => 126
[ASPId] => 130
[InsBy] => 134
[InsDate] => DateTime Object
(
[date] => 2012-06-23 17:04:51
[timezone_type] => 3
[timezone] => Asia/Kolkata
)
[UpdBy] => 11
[UpdDate] => DateTime Object
(
[date] => 2012-06-28 18:29:23
[timezone_type] => 3
[timezone] => Asia/Kolkata
)
[FName] => Kumar
[MName] => a
[LName] => Customer
[ProductName] => LenovoDesktop420
[CallOption] => InHouse
[CallType] => H.W.Installation
[ProdCompany] => Lenovo
[ProdCategory] => Desktop
[ProdUnder] => AMC
[CallStatus] => Open
[EntityId] => 134
[InsertBy] => Bhavin Rana
)
)
how can access date time value form this returned array ?
thanks in advance.
You have an outer array with numerically indexed one element [0], which is an associative array. CallDateTime as a key of that array is a DateTime object.
$array[0]['CallDateTime']->format('Y-m-d H:i:s') // 2012-06-28 00:00:00
$array[0]['CallDateTime']->getTimezone()->getName() // Asia/Kolkata
// Same with InsDate and UpdDate
$array[0]['InsDate']->format('Y-m-d H:i:s') // 2012-06-23 17:04:51
$array[0]['InsDate']->getTimezone()->getName() // Asia/Kolkata
I get this from print_r($data):
Array (
[0] => Array (
[0] => stdClass Object (
[cto_office_id] => 1
[office_name] => Airtel India
[address_line1] => Bendoor well
[phone_office1] => 12345678912
[phone_office2] => 789451234512
[address_line2] => Kankanady Circle
[city] => Mangluru
[state] => Haryana
[pin_code] => 002
[country] => India
[web_url] => airte.co.in
[office_quote] => Office
[date_registered] => 2011-11-24 05:59:51
[bill_mail_id] => 15612561
[bill_mail_id_type] =>
[acc_status] => enabled
[comments] =>
[is_account_deleted] => 0
[account_deleted_date] => 0000-00-00 00:00:00
)
)
)
I tried this $data['phone_office1'], but that does not work.
You have an object that is nested inside two arrays. You can get it out like this:
$data[0][0]->phone_office1