Solved

PHP Echo array question

Posted on 2014-11-07
5
110 Views
Last Modified: 2014-11-16
Having a hard time to echo $agentsStuff within this line of code:

schema (echo $agentsStuff[bizID]1,10);

Open in new window

0
Comment
Question by:seopti
  • 3
  • 2
5 Comments
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40429212
Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40429264
I have a bizID for each business in the database which I can echo with:

<?php echo $agentsStuff['bizID'];?>

Now I've installed an addon which adds schema org. It is printed this way:

<?php schema('someItemID');      //print schema.org rich snippets  ?>

What I would like to do is to echo the bizID as someItemID. I tried this for a few hours without success.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40429527
I tried this for a few hours without success.
Don't waste your time like that.  Just work with me.

Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40430390
When I do var_dump  on $agentsStuff I get:

array(30) { [0]=> string(6) "624082" ["bizID"]=> string(6) "624082" [1]=> string(9) "Attorneys" ["bizCatSub"]=> string(9) "Attorneys" [2]=>  .....

And there is the bizID which I need echoed as someItemID.
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40430449
It looks like you've got a results set from a query, and you've used MySQL_Fetch_Array() to retrieve the data.  That's an AntiPractice (see number 27 for an explanation of why you want to change that).

To get a different column name in the results set, and therefore a different key in the array, you can change your query to use the AS clause in the SELECT query.  Example:

SELECT bizID AS someItemID FROM myTable...

I don't understand part of this question about this line of code:
schema (echo $agentsStuff[bizID]1,10);

Open in new window

What is schema()?  Is it some kind of locally defined function?  What does "1,10" mean in this context?
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question