Jump to content


Photo
- - - - -

вывод элемента из массива


Best Answer tapakan , 03 May 2014 - 09:45

Здравствуйте. Вы работает с объектом JObject. Вывести свойства объекта можно с помощью знака "->", если позволяет доступ, а само свойство у вас уже массив. Получается так:

$userProfile->profile['favoritebook'];
Go to the full post


  • This topic is locked This topic is locked
2 replies to this topic

#1 Alexan

Alexan
  • JBZoo User (rus)
  • User rate: 0
  • posts: 128
  • topics: 43

Posted 03 May 2014 - 05:59

Приветствую,

получаем массив с элементами профиля пользователя

<?php
jimport( 'joomla.user.helper' ); 
$userProfile = JUserHelper::getProfile(); 
print_r($userProfile);
?>

на выходе:

 

JObject Object ( [_errors:protected] => Array ( ) [id] => 566 [profile] => Array ( [phone] => 8900... [website] => http://www.suite.ru [favoritebook] => Маргарита [aboutme] => [spacer] => [dob] => ) )

 

как в переменную $book получить значение favoritebook (Маргарита)

 

думал так 

$book = $userProfile[profile][favoritebook];
echo $book;

но не получается...


  • 0

#2 tapakan

tapakan
  • JBZoo User (rus)
  • User rate: 43.6
  • posts: 624
  • topics: 22

Posted 03 May 2014 - 09:45   Best Answer

Здравствуйте. Вы работает с объектом JObject. Вывести свойства объекта можно с помощью знака "->", если позволяет доступ, а само свойство у вас уже массив. Получается так:

$userProfile->profile['favoritebook'];

Edited by tapakan, 03 May 2014 - 09:48.

  • 0

#3 Alexan

Alexan
  • Topic Starter
  • JBZoo User (rus)
  • User rate: 0
  • posts: 128
  • topics: 43

Posted 03 May 2014 - 09:49

Спасибо! а то затормозил на ровном месте)


  • 0




Click to return to top of page in style!