Shorten a simple php code

How can I shorten the code below.  It's just displaying 3 lines of text from form fields completed by the client.  It currently displays as:

area1
area2
area3

and I want it to display as area1, area2, area3

<?php $field = wpbdp_get_form_field( 11 );
echo $field->display( $listing_id ); ?>

<?php $field = wpbdp_get_form_field( 13 );
echo $field->display( $listing_id ); ?>

<?php $field = wpbdp_get_form_field( 12 );
echo $field->display( $listing_id ); ?>

Open in new window

livewirewebsolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
This may be a CSS issue, not a PHP issue.  What is the contents of $field->display() in these cases?  You can use the browser "view source" to get a correct view of the data.

This is Wordpress, right?
0
livewirewebsolutionsAuthor Commented:
Yes, WP.

It seems to wrap each one in a div and a span tag.
0
Ray PaseurCommented:
What is the contents of $field->display() in these cases?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

livewirewebsolutionsAuthor Commented:
Here's the page:
http://www.thebrontevillager.ca/our-advertisers/gliding-shelf-solutions/
pw is demo5

It's the address on the right side.

Also, Is putting
echo $field->display( $listing_id ); ?>

Open in new window

every time, redundant.
0
Steve BinkCommented:
Here's one optimization:
<div class="wpbdp-form-fields">
<?php 
  /* need different numbers?  just change the array you pass into the loop */
  for ([11,13,12] as $val) {   
    $field = wpbdp_get_form_field( $val )->display($listing_id);
  }
?></div>

Open in new window

With this, you can specify how to display this information by targeting the CSS selector "div.wpbdp-form-fields" and its children.  For example:
div.wpbdp-form-fields > * { display: inline-block; }

Open in new window

0
livewirewebsolutionsAuthor Commented:
that method gives me an error:

Parse error: syntax error, unexpected 'as' (T_AS), expecting ';' in /home4/frazier/public_html/thebrontevillager.ca/wp-content/themes/Divi-Child/businessdirectory-listing.tpl.php on line 8

Line 8 is below code:
for ([12,13,11,10] as $val) {   

Open in new window

0
Steve BinkCommented:
My apologies, it should be "foreach":
<div class="wpbdp-form-fields">
<?php 
  /* need different numbers?  just change the array you pass into the loop */
  foreach ([12,13,11,10] as $val) {   
    $field = wpbdp_get_form_field( $val )->display($listing_id);
  }
?></div>

Open in new window

0
livewirewebsolutionsAuthor Commented:
I think this is above my head.  just added the foreach and nothing displays.
0
Steve BinkCommented:
Try this change and post what you see in the HTML:
<div class="wpbdp-form-fields">
<?php 
  /* need different numbers?  just change the array you pass into the loop */
  foreach ([12,13,11,10] as $val) {   
    echo "<div>Display value $val</div>";
    wpbdp_get_form_field( $val )->display($listing_id);  
  }
?></div>

Open in new window

0
livewirewebsolutionsAuthor Commented:
Cool, that has potential.

Display value 12
Display value 13
Display value 11
Display value 10
0
Steve BinkCommented:
And what is in the actual HTML?
0
Slick812Commented:
greetings livewirewebsolutions, , you gave a link to -
   http://www.thebrontevillager.ca/our-advertisers/gliding-shelf-solutions/

BUT, all that give me is a wordpress "Log In" page, so it is a useless link for us experts.

livewire, you seem to not understand how the PHP code u showed is working and it's uses in getting the output you need.

you might try this just to see what it outputs for you
<?php
for($i = 11; $i < 14; ++$i) {
   $field = wpbdp_get_form_field( $i );
   echo strip_tags($field->display( $listing_id )).',';
}
?>

Open in new window



please take the time to read the PHP manual to understand -
   http://php.net/manual/en/control-structures.for.php
   http://php.net/manual/en/function.strip-tags.php

it takes time to learn about PHP, but you must read the PHP manual to get to know what your code does and what it can do.

ask questions 4 more info
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
livewirewebsolutionsAuthor Commented:
You're right slick812.  I do need to do more research on php.  FYI - I posted the pw to the link above at the very beginning.  Thanks for everyones help.  The last code seemed to work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WordPress

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.