Error during an object call php soapclient - php

I'm getting Trying to get property 'timestamp' of non-object while trying to this code:
foreach ($BookingA as $object) {
$Bookings[] = array (
'PID' => $object->person,
'Project' => $object->levels->WSLevelIdentification->code,
'Startdate' => $object->from->timestamp,
'Endddate' => $object->to->timestamp
);
}
Where am I getting it wrong?
When i dump the data from my array i get the right value
array (size=61)
0 =>
array (size=4)
'PID' => string '2036' (length=4)
'Project' => string '19015' (length=5)
'Startdate' => string '26.07.2021 12:30:00' (length=19)
'Endddate' => string '26.07.2021 17:14:00' (length=19)
Soap-Output:
The Error is on this Line: $object->to->timestamp
What am I doing wrong?
stdClass Object ( [absence] => [checked] => [complete] => 1 [duration] => 284 [from] => stdClass Object ( [TS] => 1627295400000 [day] => 26 [hour] => 12 [min] => 30 [month] => 7 [sec] => 0 [timeInSeconds] => 1627295400 [timestamp] => 26.07.2021 12:30:00 [year] => 2021 ) [fromBookingID] => 6058 [fullDay] => [levels] => stdClass Object ( [WSLevelIdentification] => stdClass Object ( [code] => 19015 [levelID] => 1 ) ) [notice] => [person] => 2036 [properties] => stdClass Object ( [WSProperty] => Array ( [0] => stdClass Object ( [key] => 200015 [val] => true/48.2897333/16.3270315/11 ) [1] => stdClass Object ( [key] => 300015 [val] => true/48.1907349/16.5754274/29 ) ) ) [to] => stdClass Object ( [TS] => 1627312440000 [day] => 26 [hour] => 17 [min] => 14 [month] => 7 [sec] => 0 [timeInSeconds] => 1627312440 [timestamp] => 26.07.2021 17:14:00 [year] => 2021 ) [toBookingID] => 6131 )

Related

How to get status value string from razorpay array

Razorpay\Api\Payment Object ( [attributes:protected] => Array ( [id] => pay_IOx1H64JMSEFAv [entity] => payment [amount] => 100 [currency] => INR [status] => captured [order_id] => order_IOx0xic60K6TZi [invoice_id] => [international] => [method] => wallet [amount_refunded] => 0 [refund_status] => [captured] => 1 [description] => [card_id] => [bank] => [wallet] => payzapp [vpa] => [email] => sudiptobain8#gmail.com [contact] => +919134322935 [notes] => Razorpay\Api\Payment Object ( [attributes:protected] => Array ( [shopping_order_id] => 3456 ) ) [fee] => 2 [tax] => 0 [error_code] => [error_description] => [error_source] => [error_step] => [error_reason] => [acquirer_data] => Razorpay\Api\Payment Object ( [attributes:protected] => Array ( [transaction_id] => ) ) [created_at] => 1637649968 ) )
help to get [status] => captured From This in php
You need to capture objects using object (arrow) notation
<?php
echo $result->status;
?>

how to fetch data from json? [duplicate]

This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 3 years ago.
i have data in json something like that:
stdClass Object
(
[contacts] => stdClass Object
(
[14] => stdClass Object
(
[data] => stdClass Object
(
[email] => veer#gmail.com
[first_name] => veer
[last_name] =>
[user_id] => 16
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 14
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => veer
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 92
[1] => 13
[2] => 12
[3] => 9
)
[files] => Array
(
)
)
[9] => stdClass Object
(
[data] => stdClass Object
(
[email] => singh.pratibha1432#gmail.com
[first_name] => Pratibha
[last_name] => Singh
[user_id] => 8
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 9
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => pratibha
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 94
[1] => 93
[2] => 92
[3] => 91
[4] => 82
[5] => 15
[6] => 14
[7] => 13
[8] => 9
)
[files] => Array
(
)
)
[4] => stdClass Object
(
[data] => stdClass Object
(
[email] => singh.dev1432#gmail.com
[first_name] => Devesh
[last_name] => Singh
[user_id] => 7
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 4
[gravatar] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => devesh
[profile_picture] => http://localhost:8888/wordpress/wp-content/themes/wp_lms/assets/images/avatar.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 93
[1] => 92
[2] => 15
[3] => 12
[4] => 11
[5] => 9
)
[files] => Array
(
)
)
[2] => stdClass Object
(
[data] => stdClass Object
(
[email] => admin#gmail.com
[first_name] => veronica
[last_name] =>
[user_id] => 1
[owner_id] => 0
[optin_status] => 0
[date_created] => 2020-01-20 13:14:54
[ID] => 2
[gravatar] => http://localhost:8888/wordpress/wp-content/uploads/avatars/1/5dc525d984494-bpfull.jpg
[age] =>
)
[meta] => stdClass Object
(
[preferences_changed] => 1579526094
[user_login] => admin
[profile_picture] => http://localhost:8888/wordpress/wp-content/uploads/avatars/1/5dc525d984494-bpfull.jpg
[birthday] =>
)
[tags] => Array
(
[0] => 94
[1] => 92
[2] => 15
[3] => 14
[4] => 13
[5] => 9
)
[files] => Array
(
)
)
)
[status] => success
)
and now I am trying to fetch "email" from the contacts->id->data->email so for that i am using this code. I am trying to loop the things by which i can fetch email from all the ids present. and in the ids section, there is data and inside data the email is present so how can i fetch all emails from all the ids.
foreach ((Array)$body->contacts as $id => $values) {
foreach ($values as $data => $value) {
$emails = array('email'=>$value->email);
return $emails;
}
}
but it return only single data:
Array
(
[email] => veer#gmail.com
)
i want to fetch all the email like that:
Array
(
[0] => Array
(
[emails] => veer#gmail.com
)
[1] => Array
(
[emails] => singh.pratibha1432#gmail.com
)
[2] => Array
(
[emails] => singh.dev1432#gmail.com
)
[3] => Array
(
[emails] => admin#gmail.com
)
)
how can I achieve this?
Define null array and in foreach run store every email in that variable.
$emails = array();
foreach ((Array)$body->contacts as $id => $values) {
foreach ($values as $data => $value) {
$emails[] = array('emails'=>$contact->data->email;);
}
}
return $emails;

Convert php array to a much much smaller json?

I am receiving a PHP array from a webservice (soap xml).
From this array, I want to keep just a few tags and then convert it to json (see sample in the bottom).
See sample of the array I receive from webservice, below:
(*** marks the information I need in my final Json)
Array (
[0] => stdClass Object (
***[Id] => 445946
[SystemName] =>
[TrackingPixelUrl] => http://www.pix.se/picture.png
[UrlName] => Movie_Renoir_445946
***[Name] => Movie: Film
[ForeignProductId] =>
[PackageId] =>
[OrganizationId] => 1045
[Version] => 12
[TemplateId] => 81
***[Image] => stdClass Object (
[MediaId] => 41315620
[MediaType] => Image
[Url] => http://images.pix.se
[Width] => 214
[Height] => 317
[ProducedBy] =>
[CopyrightBy] =>
[ImageType] => Image
)
[Status] => Active
[PublishedDate] => 2014-11-03T10:23:09.617
[RevisionDate] =>
[ExpirationDate] => 2014-11-14T00:00:00
[Relevance] => Regional
[ParentProductId] =>
[ProductType] => Product
[IsHighlight] =>
[Attributes] => stdClass Object (
[AttributeData] => Array (
[0] => stdClass Object (
[Id] => 18895726
[AttributeId] => 125
[MetaType] => String
[Value] => stdClass Object (
***[Data] => http://www.Movie.se
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 1
[Language] => 1
)
[1] => stdClass Object (
[Id] => 18895762
[AttributeId] => 102
[MetaType] => String
[Value] => stdClass Object (
***[Data] => Text text info tinfo text Long text
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 2
[Language] => 1
)
[2] => stdClass Object (
[Id] => 20562011
[AttributeId] => 106
[MetaType] => String
[Value] => stdClass Object (
***[Data] => 70 SEK
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 3
[Language] => 1
)
[3] => stdClass Object (
[Id] => 27970127
[AttributeId] => 99
[MetaType] => String
[Value] => stdClass Object (
[Data] => Movie: Film
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 11
[Language] => 1
)
[4] => stdClass Object (
[Id] => 27970128
[AttributeId] => 101
[MetaType] => String
[Value] => stdClass Object (
***[Data] => Short info text text text
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 11
[Language] => 1
)
[5] => stdClass Object (
[Id] => 18895724
[AttributeId] => 147
[MetaType] => String
[Value] => stdClass Object (
[Data] => +46
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 2
[Language] => 0
)
[6] => stdClass Object (
[Id] => 18895725
[AttributeId] => 145
[MetaType] => String
[Value] => stdClass Object (
***[Data] => (
0410-1111111
)
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 2
[Language] => 0
)
[7] => stdClass Object (
[Id] => 18895728
[AttributeId] => 526
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 1
[Language] => 0
)
[8] => stdClass Object (
[Id] => 27970129
[AttributeId] => 115
[MetaType] => Media
[Value] => stdClass Object (
[MediaList] => stdClass Object (
[MediaObject] => stdClass Object (
[MediaId] => 41315620
[MediaType] => Image
[Url] => http://images.pix.se
[Width] => 214
[Height] => 317
[ProducedBy] =>
[CopyrightBy] =>
[ImageType] => Image
)
)
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 10
[Language] => 0
)
[9] => stdClass Object (
[Id] => 27970130
[AttributeId] => 418
[MetaType] => MultiAttribute
[Value] => stdClass Object (
[Values] => stdClass Object (
[MultiAttributeObject] => Array (
[0] => stdClass Object (
[Id] => 0
[AttributeId] => 0
[ProductId] => 0
[OrganizationId] => 0
[MultiAttributeId] => 631
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
[1] => stdClass Object (
[Id] => 0
[AttributeId] => 0
[ProductId] => 0
[OrganizationId] => 0
[MultiAttributeId] => 36
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
[2] => stdClass Object (
[Id] => 0
[AttributeId] => 0
[ProductId] => 0
[OrganizationId] => 0
[MultiAttributeId] => 2030
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
)
)
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 4
[Language] => 0
)
[10] => stdClass Object (
[Id] => 27970131
[AttributeId] => 668
[MetaType] => MultiAttribute
[Value] => stdClass Object (
[Values] => stdClass Object (
[MultiAttributeObject] => Array (
[0] => stdClass Object (
[Id] => 0
[AttributeId] => 668
[ProductId] => 445946
[OrganizationId] => 1045
[MultiAttributeId] => 2022
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
[1] => stdClass Object (
[Id] => 0
[AttributeId] => 668
[ProductId] => 445946
[OrganizationId] => 1045
[MultiAttributeId] => 2023
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
[2] => stdClass Object (
[Id] => 0
[AttributeId] => 668
[ProductId] => 445946
[OrganizationId] => 1045
[MultiAttributeId] => 2174
[MetaType] => Boolean
[Value] => stdClass Object (
[Data] =>
)
[Language] => 0
)
)
)
)
[ProductId] => 445946
[OrganizationId] => 1045
[Version] => 5
[Language] => 0
)
)
)
[Categories] => stdClass Object (
[Category] => stdClass Object (
[Id] => 16015
[OrganizationId] => 1045
[Name] => Film
[DefaultTemplateId] => 81
[Status] => Active
[ParentCategoryId] => 3568
[DisplayOrder] => 99
[Icon] =>
)
)
[GeoNode] => stdClass Object (
[Id] => 3558
[Name] => Staden med omnejd
[ParentId] => 66876
[OrgId] => 1045
[Type] => Undefined
[LeftValue] => 11
[RightValue] => 12
[CityCenterLatitude] =>
[CityCenterLongitude] =>
[CityCenterRadius] =>
)
[Occasions] => stdClass Object (
[OccasionObject] => stdClass Object (
[Id] => 19836976
[AttributeId] => 111
[ProductId] => 445946
[OrganizationId] => 1045
***[StartDate] => 2014-11-12T00:00:00
***[EndDate] => 2014-11-13T00:00:00
***[StartTime] => 0001-01-01T19:00:00
[EndTime] => 0001-01-01T19:00:00
***[ValidDays] => Wednesday Thursday
***[ArenaId] => 75316
***[ArenaName] => Moviegrafteatern Movie, Staden
[EntryTime] => 0001-01-01T00:00:00
)
)
[SupplierId] =>
[Duration] =>
[ForeignProductIds] => stdClass Object (
)
[LanguageId] => 1
)
)
I would like the final, cropped, json to look like this:
{
"Id":445946,
"Name": "Movie: Film",
"Image":{
"Url":"http://images.pix.se",
"Width":595,
"Height":709
},
"MovieUrl": "http://www.Movie.se",
"LongText": "Text text info tinfo text Long text",
"Price": "70 SEK",
"ShortText": "Short info text text text",
"Phone": "0410-1111111",
"StartDate": 2014-11-12T00:00:00,
"EndDate": 2014-11-13T00:00:00,
"StartTime": 0001-01-01T19:00:00,
"ValidDays": "Wednesday Thursday",
"ArenaId": 75316,
"ArenaName": "Moviegrafteatern Movie, Staden"
}
How can I convert this array to a much smaller JSON?
I think the only way to get this solved is an exakt mapping of your the items you need in a function an then loop through the different objects, because the structure you get with this lot of different objects is quite crappy.
function cleanUpResult(array)
{
$r = array();
foreach($item in $array){
$result = array();
$result["Id"] = $item["Id"];
$result["Name"] = $item["Name"];
$result["Image"] = array();
$result["Image"]["Url"] =$item["Image"]->Url;
$result["Image"]["Width"] =$item["Id"]->Width;
$result["Image"]["Height"] =$item["Id"]->Height;
$result["MovieUrl"] = $item["Attributes"]->AttributeData[0]->Value->Data;
$result["LongText"] = $item["Attributes"]->AttributeData[1]->Value->Data;
$result["Price"] = $item["Attributes"]->AttributeData[2]->Value->Data;;
$result["ShortText"] = $item["Attributes"]->AttributeData[4]->Value->Data;
$result["Phone"] = $item["Attributes"]->AttributeData[6]->Value->Data;
$result["StartDate"] = $item["StartDate"];
$result["EndDate"] = $item["EndDate"];
$result["StartTime"] = $item["StartTime"];
$result["ValidDays"] = $item["ValidDays"];
$result["ArenaId"] = $item["ArenaId"];
$result["ArenaName"] = $item["ArenaName"];
$r[] = $result;
}
return json_encode($r);
}
This isn't complicated, but since you want various fields from within a nested array, the simplest approach is to just iterate over the array and grab the individual fields you want to encode. I'm not sure it'll be worth the time to construct a clever filter.
For example, let's say $soapArray contains the information you provided above:
$data = array();
// iterate over the full field list
foreach ($soapArray as $soapElement) {
// construct a partial array containing the fields you want
$data[] = array(
'Id' => $soapElement['Id'],
'Name' => $soapElement['Name'],
'Image' => array(
'Url' => $soapElement['Image']->Url,
'Width' => $soapElement['Image']->Width,
'Height' => $soapElement['Image']->Height,
),
'MovieUrl' => $soapElement['Attributes']->AttributeData[0]->Value->Data,
'LongText' => $soapElement['Attributes']->AttributeData[1]->Value->Data,
);
}
// display the encoded array
echo json_encode($data);
Simply create a list of the array keys you want to white list, then remove the rest.
Assume your object is $object
//this line must come before any output is made. (echo, print, etc.)
header('Content-Type: application/json');
//whitelist. the items you want to keep
$keep = array("id", "name", "image" ...);
foreach($object as $object) {
foreach ($object as $key => $product) {
if( !in_array($key, $keep) ) { //check if the current loop key is not in the whitelist
unset($object[$key]);
}
}
}
//Then convert the array to JSon.
echo json_encode($object)
Then $object will hold only what was in the whitelist

Trying to get property of non-object in C:\wamp... (Accesing Object Array Value )

$result is
stdClass Object
(
[cityId] => 000000000020
[checkInDate] => 2013-12-20
[checkOutDate] => 2013-12-21
[customerId] =>
[customerAccountType] => SH01
[customerType] =>
[currency] => INR
[noOfRoomsRequested] => 1
[searchAvailabilityResult] => stdClass Object
(
[hotelId] => IXW1
[hotelName] => Ginger Jamshedpur
[Rate] => stdClass Object
(
[rateId] => STANDARD
[rateVersion] =>
[contractId] =>
[contractVersion] => 000
[allocationId] => IBE
[perPaxRateTypeSet] =>
[taxInclusiveInRateFlag] =>
[price] => 3499
[offerPrice] => 3499
[packageCost] => 0
[taxAmount] => 0
[luxuryTax] => 437.38
[serviceTax] => 216.24
[offerPercentageDiscount] => 0
[offerIdentifier] =>
[displayType] =>
[rateIdentifierType] => STANDARD
[rateIdTypeDesc] => STANDARD RATE
[conceptIdentifier] => ONLYROOM
[packageIdentifier] =>
[smartRate] =>
[roomGrid] => stdClass Object
(
[room] => Array
(
[0] => stdClass Object
(
[roomNumber] => 1
[roomType] => TWN
[pricingType] =>
[numOfPax] => 1
[numberOfAdults] => 1
[numberOfChildren] => 0
[numberOfJuniors] => 0
[numOfPaxForWhichRateApplied] => 1
[numOfpaxStaying] => 0
[conceptId] => ONLYROOM
[isAlternative] =>
[packageCost] => 0
[taxAmount] => 0
[luxuryTax] => 437.38
[serviceTax] => 216.24
[dayWiseRate] => stdClass Object
(
[forDay] => stdClass Object
(
[date] => 2013-12-20
[price] => 3499
[offerPrice] => 3499
[taxAmount] => 0
[luxuryTax] => 437.38
[serviceTax] => 216.24
[availability] => 42
)
)
)
[1] => stdClass Object
(
[roomNumber] => 1
[roomType] => STD
[pricingType] =>
[numOfPax] => 1
[numberOfAdults] => 1
[numberOfChildren] => 0
[numberOfJuniors] => 0
[numOfPaxForWhichRateApplied] => 1
[numOfpaxStaying] => 0
[conceptId] => ONLYROOM
[isAlternative] => 1
[packageCost] => 0
[taxAmount] => 0
[luxuryTax] => 437.38
[serviceTax] => 216.24
[dayWiseRate] => stdClass Object
(
[forDay] => stdClass Object
(
[date] => 2013-12-20
[price] => 3499
[offerPrice] => 3499
[taxAmount] => 0
[luxuryTax] => 437.38
[serviceTax] => 216.24
[availability] => 21
)
)
)
)
)
[policies] => stdClass Object
(
[policy] => Array
(
[0] => stdClass Object
(
[policyType] => ADV
[policyCode] => ADVIXW1001
)
[1] => stdClass Object
(
[policyType] => CAN
[policyCode] => CNXIXW1002
)
[2] => stdClass Object
(
[policyType] => AMD
[policyCode] => AMDIXW1002
)
[3] => stdClass Object
(
[policyType] => NOS
[policyCode] => NSIXW1002
)
[4] => stdClass Object
(
[policyType] => CCP
[policyCode] => CIOIXW1001
)
)
)
)
)
)
i want to access [rateIdTypeDesc] => STANDARD RATE
what i tried
foreach ($result->searchAvailabilityResult->Rate as $item)
{
echo $item->rateIdTypeDesc; echo "<hr>";
}
Notice: Trying to get property of non-object in C:\wamp
foreach ($result->searchAvailabilityResult->Rate as $key=>$item) {
if($key == 'rateIdTypeDesc'){
echo $item;
}
}

How to filter out an object from an array of objects?

I've got an array of objects as follows ; how can I filter out (remove) the objects that have admins->member = 11 ?
In this example, the resulting array object would only have the 1st object that [245] at the start.
Array
(
[245] => stdClass Object
(
[name] => Programmation Web
[description] =>
[public] => 0
[jointype] => controlled
[grouptype] => course
[membershiptype] => member
[reason] =>
[role] => tutor
[ctime] => 2011-10-12 14:41:35
[mtime] => 0000-00-00 00:00:00
[image] =>
[session_id] => 28
[session_name] => Hiver 2012
[membercount] => 1
[favorite] =>
[requests] => 0
[id] => 245
[members] => Array
(
[0] => stdClass Object
(
[id] => 11
[name] => Yves Otis (otisyves)
)
)
[projects] => Array
(
[0] => stdClass Object
(
[id] => 1923
[title] => Sans titre (1)
[description] =>
[owner] => 11
[ownerformat] =>
[group] =>
[institution] =>
[startdate] =>
[stopdate] =>
[ctime] => 2011-10-12 13:24:26
[mtime] => 2011-10-12 13:24:26
[atime] => 2011-10-12 13:24:26
[submittedgroup] => 245
[submittedhost] =>
[submittedtime] => 2011-10-12 17:00:41
[numcolumns] => 3
[layout] =>
[theme] =>
[template] => 0
[copynewuser] => 0
[type] => portfolio
[visits] => 0
[allowcomments] => 1
[approvecomments] => 0
[skills] =>
[instructions] =>
[accessconf] =>
[image] =>
[competencesvisees] =>
[consignes] =>
[fichierconsignes] =>
[groupevise] =>
)
)
[project_count] => 1
[admins] => Array
(
[0] => stdClass Object
(
[member] => 11
[firstname] => Yves
[lastname] => Otis
)
)
[topic_name] => Le PHP
[activites] => Array
(
[0] => stdClass Object
(
[topic_name] =>
[topic_id] => 42
[post_parent] => 107
[post_body] => Oui moi aussi je me demande ça.
[post_id] => 109
)
)
[forums] => Array
(
[0] => stdClass Object
(
[forum_name] => Discussion générale
[forum_id] => 101
)
)
)
[246] => stdClass Object
(
[name] => Les bases de données
[description] =>
[public] => 0
[jointype] => controlled
[grouptype] => course
[membershiptype] => admin
[reason] =>
[role] => admin
[ctime] => 2011-10-13 15:27:30
[mtime] => 0000-00-00 00:00:00
[image] =>
[session_id] => 27
[session_name] => Automne 2011
[membercount] => 0
[favorite] =>
[requests] => 0
[id] => 246
[project_count] => 0
[topic_name] => Difficulté
[activites] => Array
(
[0] => stdClass Object
(
[topic_name] =>
[topic_id] => 44
[post_parent] => 111
[post_body] => Ouah!
[post_id] => 112
)
)
[forums] => Array
(
[0] => stdClass Object
(
[forum_name] => Le MySQL
[forum_id] => 103
)
)
)
)
I'd like to check against the index
$arr = array_filter($arr, function($item) {
if (!isset($item->admins) || !is_array($item->admins)) {
return false;
}
foreach ($item->admins as $admin) {
if ($admin->member == 11) {
return true;
}
}
return false;
});

Categories