Link to home
Start Free TrialLog in
Avatar of lawrence_dev
lawrence_dev

asked on

How do I fix this strpos statement?

How do I fix the STRPOS statement?  What am I doing wrong here?


if ($Brand="PREMIUM POWER" AND (strpos($ModelArray,'Latitude'|'Vostro'|'ChemBook'|'Inspiron'|'JetBook'|'Precision'|'Studio'|'XPS')) !== false) {
    $NewBrand="Dell";
    }  else if ($Brand="PREMIUM POWER" AND (strpos($ModelArray,'ThinkPad')) !== false) {
    $NewBrand="IBM";
	}  else if ($Brand="PREMIUM POWER" AND (strpos($ModelArray,'Presario'|'Pavilion')) !== false) {
    $NewBrand="HP";
    } else {
	$NewBrand=$row5[Manufacturer];
	}

Open in new window

Avatar of Marco Gasi
Marco Gasi
Flag of Spain image

Line 3 must be
else if ($Brand="PREMIUM POWER" AND (strpos($ModelArray,'ThinkPad') !== false)) {

Open in new window

and line 5 must be:
}  else if ($Brand="PREMIUM POWER" AND (strpos($ModelArray,'Presario'|'Pavilion') !== false)) {

Open in new window

There's a lot wrong with your code.

Firstly, a single = is an assignment - for compasrison your need a double ==

AND in your if statement should be &&

You can't use a single strpos call for multiple words - you need to loop through them. Create an array and loop through them one by one.
Avatar of lawrence_dev
lawrence_dev

ASKER

Chris,
Please advise how to correctly structure.  Thanks for your help!
No worries. can you show me what's in $modelarray. Is it actually an array as the name suggests
It is really not an 'array' per se.   It is pipe delimited.  Here it is:

ThinkPad i1700|ThinkPad i1720|ThinkPad i1721 etc

Thanks for your help!!
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Chris!