Member Avatar for LastMitch

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!

Recommended Answers

All 4 Replies

Member Avatar for Zagga

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.

commented: Thanks for the explanation! +5
Member Avatar for 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!

Member Avatar for LastMitch

@Zagga

I made some adjustment and it echo correctly. Thanks!

Member Avatar for LastMitch

@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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.