Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.