Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read 2nd part: comma delim. form value

Status
Not open for further replies.

DeZiner

Programmer
May 17, 2001
815
US
My shopping cart returns a form field called status to me with a comma delim. value:
Code:
<input type=&quot;hidden&quot; name=&quot;status&quot; value=&quot;275394,This transaction has been approved.,Y,404142852&quot;>

Notice however the the &quot;Values&quot; are not in single or double quotes. I need to be able to check for the word &quot;approved&quot; in the string of values and if exists, send an email.

I thought that setting $myvar = array($status) then printing $status[1] would give me the second part. No go.

How can I check for the key word &quot;approved&quot;? DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
What Am I doing wrong here? I tried split() before.

$MyStatus = array ($status);
list($MyStatus)= split (&quot;,&quot;, $finstat, 2);

finstat is returning empty. DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
I don't know anything about $finstat -- I don't know how you're assigning value(s) to it.

What I had in mind was:

$myarray = split (',', $status);

if (some test on $myarra[1])
{
.
.
.
}


Conversely, if you only need to see whether the string &quot;approved&quot; appears in $status, then use strstr() ( to find the substring. Want the best answers? Ask the best questions: TANSTAAFL!
 
About split:
The split() function returns an array.
Your assignment assigns the resulting array to a function result:
list($myArray) = split(',',$finstat);
What you want to do is
$myArray = split(',',$finstat);

Alternate solution:
Use the strstr function to check for the word 'approved':
$needle = 'approved';
if(strstr($haystack,$needle)) {
echo &quot;found it.&quot;;
} else {
echo &quot;not found.&quot;;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top