0

I have an array that looks like this,

    Array
(
    [candidate_id] => 1
    [first_name] => Simon
    [surname] => Ainley
    [gender] => male
    [talent] => presenter
    [DOB] => 1987-06-12
    [Location] => Huddersfield
    [height] => 6' 3"
    [eyes] => blue
    [hair] => brown
    [hair_length] => short
    [accents] => Native english
    [training] => none
    [unions] => Actors guild
    [date_created] => 2011-10-11 00:00:00
)

However when I don the following,

<?php foreach ($results as $k => $v) : ?>
    <?php print_r($v); ?>
<?php endforeach; ?>

Using this I am getting output,

1 S A m p 1 H 6 b b s N n A 2
3
  • That is definitely not your array: ideone.com/KdsMV Commented Oct 11, 2011 at 15:12
  • @WesleyMurch: -Or- not the code :) Commented Oct 11, 2011 at 15:28
  • did yo tried with simple echo? Commented Oct 12, 2011 at 11:46

1 Answer 1

1

This happens when you try and echo an array element thats actually a string. eg.

$string = "hello";
echo $string[1]; // echos "e"

Make sure the structure of $results is what you think it is and you are using print_r() on the correct variable.

See also: String access and modification by character Docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.