1
내가 내가 내가 내가 echo "<pre>";print_r($doc['Segmentation']);echo "</pre>";
를 사용하는 경우알림 : 정의되지 않은 인덱스 : PHP로 분할?
Array
(
[0] => Array
(
[_id] => 1
[Trends] => Youthful Truths
[Segmentation] => stdClass Object
(
[Lifestyle] => stdClass Object
(
[SEC] => Array
(
[0] => SEC A
)
[LSM] => stdClass Object
(
[10-12] => 235
[13-15] => 585
[16-18] => 525
)
)
[Generation] => stdClass Object
(
[Global] => Array
(
[0] => Gen Z
[1] => Millennials
[2] => Gen X
)
[India] => Array
(
[0] => Gen Z
[1] => Millennials
[2] => Liberalized Gen
)
)
)
[Location] => stdClass Object
(
[Global] => Array
(
)
[Country] => Array
(
[0] => india
)
[UrbanRural] => Array
(
[0] => urban
)
)
[Relevance] => stdClass Object
(
[HoriZontal] => Array
(
[0] => Marketing
[1] => Branding
)
)
...etc
결과 가지고 echo "<pre>";print_r($doc);echo "</pre>";
를 사용하는 경우 PHP 코드를 PHP 코드
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query([]);
$cursor = $manager->executeQuery('trends.trends_new_collection', $query);
$cursor->setTypeMap(['root' => 'array']);
$doc = $cursor->toArray();
echo "<pre>";print_r($doc['Segmentation']);echo "</pre>";
을 folowing으로 몽고 모음에서 문서를 얻기 위해 노력을해야 PHP와 MongoDB를 사용했다 오류가 발생했습니다. Notice: Undefined index: segmentation in
'stdClass Object'에 액세스하는 방법은 무엇입니까? 어떻게 Mongodb와 PHP 에서이 결과에 액세스 할 수 있습니까?
K 그것은 일했다 V하지만 어떻게'stdClass Object'에 액세스하는 방법? –
다음과 같이 시도하십시오'$ value = $ doc (array);' –