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];
}
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.
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.
ASKER
Chris,
Please advise how to correctly structure. Thanks for your help!
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
ASKER
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!!
ThinkPad i1700|ThinkPad i1720|ThinkPad i1721 etc
Thanks for your help!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Chris!
Open in new window
and line 5 must be:Open in new window