We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,687 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Having issue with Assigned Array Keyword

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
3 Hours
Discussion Span
7 Months Ago
Last Updated
5
Views
Question
Answered
LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

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.

Zagga
Posting Whiz
366 posts since Dec 2009
Reputation Points: 45
Solved Threads: 77
Skill Endorsements: 4

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!

diafol
Keep Smiling
Moderator
10,630 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,506
Skill Endorsements: 57

@Zagga

I made some adjustment and it echo correctly. Thanks!

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@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

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
Question Answered as of 7 Months Ago by diafol and Zagga

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0742 seconds using 2.77MB