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

  • Home
  • SEARCH
  • 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 8857213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:32:13+00:00 2026-06-14T14:32:13+00:00

Is it possible to achive this? i have some arrays Array ( [1] =>

  • 0

Is it possible to achive this?

i have some arrays

Array
(
    [1] => Model_Like Object
        (
            [_is_new:protected] => 
            [_frozen:protected] => 
            [_data:protected] => Array
                (
                    [id] => 1
                    [user_id] => 5
                    [liked_by] => 1
                )

            [_custom_data:protected] => Array
                (
                )

            [_original:protected] => Array
                (
                    [id] => 1
                    [user_id] => 5
                    [liked_by] => 1
                )

            [_data_relations:protected] => Array
                (
                )

            [_original_relations:protected] => Array
                (
                )

            [_reset_relations:protected] => Array
                (
                )

            [_view:protected] => 
            [_iterable:protected] => Array
                (
                )

        )

    [2] => Model_Like Object
        (
            [_is_new:protected] => 
            [_frozen:protected] => 
            [_data:protected] => Array
                (
                    [id] => 2
                    [user_id] => 5
                    [liked_by] => 2
                )

            [_custom_data:protected] => Array
                (
                )

            [_original:protected] => Array
                (
                    [id] => 2
                    [user_id] => 5
                    [liked_by] => 2
                )

            [_data_relations:protected] => Array
                (
                )

            [_original_relations:protected] => Array
                (
                )

            [_reset_relations:protected] => Array
                (
                )

            [_view:protected] => 
            [_iterable:protected] => Array
                (
                )

        )

    [4] => Model_Like Object
        (
            [_is_new:protected] => 
            [_frozen:protected] => 
            [_data:protected] => Array
                (
                    [id] => 4
                    [user_id] => 5
                    [liked_by] => 6
                )

            [_custom_data:protected] => Array
                (
                )

            [_original:protected] => Array
                (
                    [id] => 4
                    [user_id] => 5
                    [liked_by] => 6
                )

            [_data_relations:protected] => Array
                (
                )

            [_original_relations:protected] => Array
                (
                )

            [_reset_relations:protected] => Array
                (
                )

            [_view:protected] => 
            [_iterable:protected] => Array
                (
                )

        )

)

And i only want tho show one matching result.

<?php foreach ($user->likes as $likes): ?>
<?php if($likes['liked_by'] == $logged_in_user_id): ?>
     <?php echo "you like it" ?>
<?php else: ?>
    <?php echo "you dont like it" ?>
<?php endif; ?>
<?php endforeach; ?>

and this way i get the following results

you like it  you dont like it    you dont like it

Is there away to only show the matchig result?

  • 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-14T14:32:15+00:00Added an answer on June 14, 2026 at 2:32 pm

    use return; that jumps out from the loop

    <?php 
       $result = "you dont like it";
       foreach ($user->likes as $likes) {
         if($likes['liked_by'] == $logged_in_user_id) {
           $result = "you like it";
         }
       }
       echo $result;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert multidimensional array into single array I have this array: Array (
I have written some code that stores values inside a array of arrays. I
Is there any possible way to achieve this? For instance, I have an I/O
Have been looking around for a solution to this and have found some help
I'm having trouble aggregating multiple arrays into one big array, I think this should
I have a php file with some arrays in it. I want to modify
The problem is like this: I have an array of 500 pointers which point
Is it possible to achieve this task with a single MySQL query? Table urls
I am wondering if it's possible to achieve this using the jQuery UI Slider.
Is it possible to write this query in codeigniter active records? $Main_Nav_Query = mysql_query(SELECT

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.