Welcome to WebmasterWorld Guest from 23.20.137.66

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)

5+ Year Member



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)

5+ Year Member



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)

5+ Year Member



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

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



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

Featured Threads

Hot Threads This Week

Hot Threads This Month