Welcome to WebmasterWorld Guest from 54.234.244.30

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

php array structuring to compare variables

compare array values

     
10:20 am on Oct 21, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 20, 2009
posts:70
votes: 0


Hi guys,

Is there a better structure to compare array values?

STRUCTURE:
$value1[]=true;
$vaule2[]='miketheman';
$value3[]='mikes content';

$value1[]=true;
$value2[]='someone';
$value3[]='someones content';

CONDITIONAL CODING:
$totalrecords=count($vaule1);
$recordslooped=0; while ($recordslooped < $totalrecords ¦¦ $target==0){

if ($value2[$recordslooped] == 'miketheman'){
$value2=$value2[$recordslooped];
$value2=$value2[$recordslooped];
$target=1;
}

$recordslooped++; }

GOAL:
echo 'Value2: '.$value2.'<br>Value3: '.$value3;

Display:
Vaule2: miketheman
Value3: mikes content

ANY SUGGESTIONS GREATLY APPRECIATED

10:26 am on Oct 21, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 20, 2009
posts:70
votes: 0


I was thinking array_filter would be better than the conditional coding? Is there a way to filter only based on the value?
9:26 pm on Oct 21, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Oct 20, 2009
posts:70
votes: 0


anyone?
12:53 am on Oct 30, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


It's not really clear what you are attempting. array_diff and array_intersect() are two functions I use quite often.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members