jaxdevil Posted November 2, 2007 Share Posted November 2, 2007 Ok, I am trying to display a single field from an explode string. I have no idea how to do this. The script already explodes the string and loops the data displaying it in table format.. // load a temporary array with the values returned from authorize.net $temp_values = explode('|', $this->response_string); // load a temporary array with the keys corresponding to the values // returned from authorize.net (taken from AIM documentation) $temp_keys= array ( 'Version','ResponseCode','Code','Description','AuthCode', 'AVSResultCode','CVVResultCode','TransID','RefTransID','TransHash','TestMode','' ); The above code is what explodes the string and labels it. the below code is what makes the loop which displays the data in table format... function dump_response() { // Used for debuggin, this function will output all the response field // names and the values returned for the payment submission. This should // be called AFTER the process() function has been called to view details // about authorize.net's response. echo "<h3>authorizenet_class->dump_response() Output:</h3>"; echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\"> <tr> <td bgcolor=\"black\"><b><font color=\"white\">Index </font></b></td> <td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td> <td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td> </tr>"; $i = 0; foreach ($this->response as $key => $value) { echo "<tr> <td valign=\"top\" align=\"center\">$i</td> <td valign=\"top\">$key</td> <td valign=\"top\">$value </td> </tr>"; $i++; } Now what I am trying to do is display JUST the AuthCode. I duplicated the loop foreach string and it displays everything in one line. Here is the code.. $i = 0; foreach ($this->response as $key => $value) { echo "<tr> <td valign=\"top\" align=\"center\">$i</td> <td valign=\"top\">$key</td> <td valign=\"top\">$value </td> </tr>"; $i++; } And the output it displays is... 0 Version 1.0 1 ResponseCode 1 2 Code 1 3 Description (TESTMODE) This transaction has been approved. 4 AuthCode 000000 5 AVSResultCode P 6 CVVResultCode 7 TransID 0 8 RefTransID B01BFA1E733BC8491FB07B8586783EF6 9 TransHash Anyone know how I can make the field number 4 (AuthCode) display on its own? I want to make it display in a form that I can update a database with. I have that part covered, I just need to find out how to get just that field to display. Thanks in advance guys! Link to comment https://forums.phpfreaks.com/topic/75751-solved-display-specifc-field-from-explode-string/ Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 you could do this //data array $arrData = array(); // load a temporary array with the values returned from authorize.net $temp_values = explode('|', $this->response_string); // load a temporary array with the keys corresponding to the values // returned from authorize.net (taken from AIM documentation) $temp_keys= array ( 'Version','ResponseCode','Code','Description','AuthCode', 'AVSResultCode','CVVResultCode','TransID','RefTransID','TransHash','TestMode','' ); for ($i=0;$i<count($temp_keys);$i++) { $arrData[$temp_keys[$i]] = $temp_values[$i]; } //then you could do this echo $arrData['Version']; Link to comment https://forums.phpfreaks.com/topic/75751-solved-display-specifc-field-from-explode-string/#findComment-383350 Share on other sites More sharing options...
jaxdevil Posted November 2, 2007 Author Share Posted November 2, 2007 rajivgonsalves you the man!!! That was fast!! Link to comment https://forums.phpfreaks.com/topic/75751-solved-display-specifc-field-from-explode-string/#findComment-383353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.