homepage Welcome to WebmasterWorld Guest from 54.161.236.92
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php array structuring to compare variables
compare array values
miketheman




msg:4010676
 10:20 am on Oct 21, 2009 (gmt 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

 

miketheman




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

I was thinking array_filter would be better than the conditional coding? Is there a way to filter only based on the value?

miketheman




msg:4011079
 9:26 pm on Oct 21, 2009 (gmt 0)

anyone?

coopster




msg:4016005
 12:53 am on Oct 30, 2009 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved