0

Hi

I'm still having trouble understand arrays since I join Daniweb a few months ago. I thought I got a handle it but it seems I need to practice more and write more arrays correctly.

This the issue I'm having I can't echo the words

<?php

$printer_machine = array("Copier", "Inkjet", "Laser", "Photo");

echo "$printer_machine: " .$printer_machine[3]. "<br>";

$type_machine = array('copier' => "Copier & Multipurpose",
                      'inkjet' => "Inkjet Printer",
                       'laser' => "Laser Printer",
                       'photo' => "Photographic Paper");

echo "$type_machine: " .$type_machine['photo']. "<br>";

?>

Any Suggestions and explanation will help. I appreciate it. Thanks!

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by LastMitch
1

Hi LastMitch,

On line 5 you are trying to echo $printer_machine (which doesnt exist as a variable) and then you echo $printer_machine[3] which does exist.

Try changing the line to

echo "Printer Machine: " . $printer_machine[3] . "<br>";

The same thing for line 12.

Votes + Comments
Thanks for the explanation!
1

Eh? Did LM change the post after your suggestion. Either way this post does not make sense. LM - if you did - just a simple thanks would've sufficed. If you didn't, Zagga - you're drunk!

0

@Zagga

I made some adjustment and it echo correctly. Thanks!

0

@diafol

Eh? Did LM change the post after your suggestion. Either way this post does not make sense. LM - if you did - just a simple thanks would've sufficed. If you didn't, Zagga - you're drunk!

I think I didn't check my code! I type this by hand so I didn't pay attention what I did. I felt tired.

But it's solve now! Yes, I did said "Thanks" to Zagga

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.