Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:13:40+00:00 2026-06-01T01:13:40+00:00

I am fetching an array and I would like to assign attributes of items

  • 0

I am fetching an array and I would like to assign attributes of items within the array to individual variables. For example, I want to assign a variable named user_1_name to include userInfo.name from the first userID and user_2_name to include userInfo.name from the second userID. Here is the code as it stands now, it uses a proprietary method named ‘get_friend_list’:

{assign var="friend_list" value=""}
{get_friend_list snid=$TOSNID snuid=$TOUID gameid=$GAMEID assign="friend_list"}
{if $friend_list|@count > 0}
  {foreach from=$friend_list key=userId item=userInfo name=friend_list}
    {if $smarty.foreach.friend_list.index < 4 && $smarty.foreach.friend_list.index >= 0 && !empty($userInfo.user_uid) }                             
      ***VARIABLE ASSIGNMENT HERE***
    {/if}
  {/foreach}
{else}
{/if}

If this is an unclear question, let me know and I will attempt to clear it up.

Thanks

EDIT: BTW, if you didn’t notice, I am using Smarty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:13:42+00:00Added an answer on June 1, 2026 at 1:13 am

    Did you try:

    {assign var="user_{$smarty.foreach.friend_list.index}_name" value=$userInfo.name}
    

    ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue like, when I try to seperate string and fetching array
I am fetching an array of floats from my database but the array I
In my rails app the model is fetching some XML and returning an array.
I am developing my own class model for my database and I would like
I am using this array( as an example) http://pastebin.com/M0ZJgAVs i am using json_encode() on
I am fetching an array of animal names, types, age, etc. from a MySQL
i am fetching array of dates which come between two date.. and i am
I am fetching an array of data from SQL, and then concatenating them as
I am having one array where i am fetching data from database for some
I have an array of objects that I'd like to filter using a predicate,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.