I am having kind of stupid problem:P

<?php
echo $url; // In my php files $url contain multiple values
?>

This works fine
The different values of url get displays properly
For e.g
http://www.google.com
http://www.daniweb.com

That's perfect

Now when i tried to echo the variable in some html

<?php
$url = something; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>

ONLY the first occurence of the variable url get displayed(i.e http://www.google.com)
HOW to make it display all values of $url in HTML
HTML need to be like this

<html>
<td><input type="text" size="50" value="<?php echo $url(first occurence)?>"/></td>
</html>
<html>
<td><input type="text" size="50" value="<?php echo $url(seconds occurence)?>"/></td>
</html>

Hope i will get this done soon

Thanks

It would be this, surely?:

<?php
$url = "something"; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url; ?>"/></td>
</html>

Ohhhhhhhh!! You're talking about arrays! Apologies!

So you'd have a list of values:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo $url;

   }

   // output
   //www.google.com www.yahoo.com wwww.website.com 
?>

So in theory, it would be something like this:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo '<td><input type="text" size="50" value="' .$url. '"/></td>';

   }
?>

You are partly right , the thing is that i want to echo the variable within html

Like this

     <html>
     <td><input type="text" size="50" value="<?php echo $url?>"/></td>
     </html>

But with all occurence of $url
$url is in a loop that's why it has multiple values
I think i expressed myself clear enough:P

It's unclear.

What your suggesting is that $url IS defined as a single variable, but has loads of values.. Almost to say:

$url = "www.google.com, www.yahoo.com";

Which, if this is the case then it's the wrong way to go around things.

I don't get what you mean "echo the variable within HTML" my example did that?

No $url is in a loop , it has one value @ a time
suppose i am uploading multiple files @ a time and storing the url in $url
Now the problem is that the only the first value of $url is printed in the html

?php
$url = something; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>

What is what it to do is to print Code below multiple times and show the difference values of $url Not just the first one

<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>

Right, show me (in your php file) how you're defining $url please. :)

i.e. The actual script!!

Fixed it myself
How i did

I put php tags within html + added a loop

Ok. Glad you sorted it out. Next time, be more specific in what it is you're actually trying to do!

<?php
ob_start();

$test = "Hello World";
echo $test;
?>

output:
Hello world

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.