Jump to content

[SOLVED] New Array Question


ballhogjoni

Recommended Posts

My original array looks like this: array([0] => 1|test|test1|etc...) So I need some code to seperate the the value by the | mark. That what this code does:

<?php

$test = array($resp);

$new_array = array();

foreach ($test as $key => $val) {

      $new_array[$key] = explode('|',$val);

}

echo '<pre>' . print_r($new_array,true) . '</pre>';  // debug

?>

 

Now I want to echo (print into the browser) the value of index 2 only, not the entire array.

Actually, a closer look reveals it is mutidimensional.

 

What does....

 

<?php
$test = array($resp);
$new_array = array();
foreach ($test as $key => $val) {
      $new_array[$key] = explode('|',$val);
}

echo "<pre>";
print_r($new_array,true);
echo "</pre>";

?>

 

produce? And which part do you want?

<?php
Array
(
    [0] => Array
        (
            [0] => 3
            [1] => 1
            [2] => 6
            [3] => (TESTMODE) The credit card number is invalid.
            [4] => 000000
            [5] => P
            [6] => 0
            etc...to the 72nd index of this array
        )

)
?>

 

I want to be able to print the value of whatever index I want. I.E. this index and value pair [3] => (TESTMODE) The credit card number is invalid. should just show the value part in a browser not the actual index.

 

Also I don't want to print all the values of all the indexes.

 

Example code that I think should work but doesn't is:

echo $new_array[3]; //output should be: (TESTMODE) The credit card number is invalid.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.