Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Append number to array

Posted on 2014-12-02
19
126 Views
Last Modified: 2014-12-04
I would like to add a number to this array:

<div class="stars" data-id="<?php echo $attorneysStuff['bizID'];?>2" data-stars="10" data-title="Pricing">

<?php schema($attorneysStuff['bizID'],10);?>

</div>


So it should be like this. In this case "2" is added, but it will not work this way:

[code]

<?php schema($attorneysStuff['bizID2'],10);?>

Open in new window

0
Comment
Question by:seopti
  • 7
  • 7
  • 2
  • +1
19 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40477135
Whats the error - there is nothing wrong with the code
0
 

Author Comment

by:seopti
ID: 40477169
The problem with the code is, there is no bizID2, there is only a bizID.

So this will code will not append the number "2" to the bizID.

<?php echo $attorneysStuff['bizID2'];?> 

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 40477193
Not following you - if it doesn't exist then why are you trying to access it or do you mean

<?php echo $attorneysStuff['bizID']."2";?>
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:seopti
ID: 40477302
Thank you but still looking for the solution of this:

<?php schema($attorneysStuff['bizID'],2,10);?>

bizID needs the element 2 added at the and, after this ,10
0
 
LVL 58

Expert Comment

by:Gary
ID: 40477313
What is schema
0
 

Author Comment

by:seopti
ID: 40477332
schema is a function.

<?php schema('someItemID');      //print schema.org rich snippets
schema('someItemID',10);      //print schema.org rich snippets with 10 - as maximum possible rating

Usually I append a sub-id to the bizID like this:
<?php echo $attorneysStuff['bizID'];?>2

But in the case above I have to get the syntax for:
<?php schema($attorneysStuff['bizID'],2,10);?>

I'm trying this for hours but without any result.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40477341
And whats the code?
You can't ask use to help you do something and not show the code
0
 

Author Comment

by:seopti
ID: 40477366
This is the code for the schema function:

 USAGE EXAMPLE (your_file.php):
   
   <?php
   
      include_once ('www.your_site.com/path_to/snippets.php');		//include snippets.php file
      
      $itemID='myItem';		//item ID for which rich snippets will be displayed
      
      //call one of the functions, depending on which rich snippets you already use in your project
      schema($itemID);		//(recommended)
      //microdata($itemID);
      //microformat($itemID);
      //PDFa($itemID);
      
   ?>
   
   
*/





//template for schema.org
function schema($item_id, $best=5, $round=null){
    $stats = getStats($item_id, $best, $round);			//get rating from DB
    
	//in case of any database related errors
	if($stats==0) {echo ' !Error! '; return;}
	
	//dont print snippet if item has less then 1 vote to avoid google error message
//	if($stats['votes']<1) {echo '<br />item has less then 1 vote'; return;}
	
	//markup template for scheme.org. Edit it as you like.  
	$template = <<< EOF
	
	
<div itemscope itemtype="http://schema.org/CreativeWork">
	<a itemprop="url" href="{$stats['url']}">
		<span itemprop="name">{$stats['title']}</span>
	</a> 
	<span itemprop="aggregateRating"	itemscope itemtype="http://schema.org/AggregateRating">
		<meta itemprop="worstRating" content = "0">
		<span itemprop="ratingValue">{$stats['average']}</span> 
		out of <span itemprop="bestRating">{$stats['best']}</span> 
		(based on <span itemprop="ratingCount">{$stats['votes']}</span> ratings)
	</span>

</div>

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
ID: 40477392
bizID needs the element 2 added at the and, after this ,10
Doesn't make sense
0
 
LVL 12

Expert Comment

by:tel2
ID: 40477441
> Doesn't make sense
I'm struggling with this use of the English language too, Gary.
A bit (or even a byte) more time spent in giving enough info and writing things clearly could save everyone a lot of time in the long run, IMHO.  It's fortunate the some experts are very patient, which is impressive considering what they get "paid".
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40477534
Let's try this.

1. Please show us the data you have for input - not the code, just the data.  If you want you can use var_dump() to print out the values of the data.

2. Please show us the output you want to get from the data.

With that information we can usually show you the exact code to achieve the result.
0
 
LVL 12

Expert Comment

by:tel2
ID: 40477833
You must be better than you even know, Ray.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40477840
0
 

Author Comment

by:seopti
ID: 40482164
Of course Rays question was the answer. His question helped me solving this problem.

The other posters complained they are underpaid and it maked no sense, Ray provided a question which led to a solution so where is the problem?
0
 

Author Comment

by:seopti
ID: 40482165
Maybe you should pay the experts more so they will not be that frustrated about solving questions, just a suggestion.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40482174
posters complained they are underpaid
No one complained about being underpaid, tel2's comment was sarcasm because we are not paid.
All experts on here do it of their own free will

Now care to explain how a question asking for the data is an answer.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40482180
Maybe you should pay the experts more...
Ha!  Yes please raise my salary from E-E by at least 10%.  So many questions are answered by just getting from the initial question to the SSCCE!
0
 

Author Comment

by:seopti
ID: 40482243
They don't pay you but I pay them. So you for sure have high morals if you help poor coding souls if you are not paid :)

No rellay, they really don't pay the experts, what a shame!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

828 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