Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Compare 2 arrays

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Paris
Smarty Rookie


Joined: 02 Dec 2009
Posts: 13

PostPosted: Wed Feb 18, 2015 2:52 pm    Post subject: Compare 2 arrays Reply with quote

Hi,
I have a site with smarty and now i want to compare 2 arrays for unique values... tried everything but i can't get it write.

I have two database querys:
Code:
$winks = $osDB->getAll( 'SELECT ref_userid FROM ! ', array(VIEWS_WINKS_TABLE) );

$user = $osDB->getAll( 'SELECT id FROM ! ', array(USER_TABLE) );   

and in my template foreach;
Code:
{foreach item=item key=key from=$winks}
   <div>
   userid = {$item.owner}<br /></div>{/foreach}

{foreach item=item key=key from=$user}
   <div>
   userid = {$item.id} <br /></div>{/foreach}   

it gives (shorten):
Code:

userid = 957
userid = 94
----------------------------------------------------
userid = 2
userid = 94
userid = 95
userid = 176
userid = 179

I want to see if the id's 957 and 94 exists in the other string.. so in this case it must give 957 because that id das not exist in the other tabel.

I would appreciate al lot any help i get Smile
regards
Paris
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Feb 18, 2015 6:03 pm    Post subject: Reply with quote

http://php.net/manual/en/ref.array.php
Not a Smarty question.
Back to top
View user's profile Send private message
Paris
Smarty Rookie


Joined: 02 Dec 2009
Posts: 13

PostPosted: Thu Feb 19, 2015 9:21 am    Post subject: Reply with quote

This is a smarty question.. the database query outcome is (shorten):
Code:
Array ( [0] => Array ( [owner] => 957 ) [1] => Array ( [owner] => 94 ) )

and
Code:
Array ( [0] => Array ( [id] => 2 ) [1] => Array ( [id] => 94 ) [2] => Array ( [id] => 95 ) [3] => Array ( [id] => 176 ) [4] => Array ( [id] => 179 ) [5] => Array ( [id] => 195 ) [6] => Array ( [id] => 197 ) [7] => Array ( [id] => 198 ) [8] => Array ( [id] => 200 ) )

nothing with the php array functions seems to work with this kind of array.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Feb 19, 2015 10:40 am    Post subject: Reply with quote

This is not a Smarty question. Smarty is a template engine.
To process your data, please use business logic of your application.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP