TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-29-2010, 12:19 AM   #1 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Red face For each question

Hello,

PHP Code:
if(isset($videos[0]['url'])) {

            foreach (
$videos as $video)
            {

$yonlen $video['url'];
echo 
"<a href=$yonlen>Download</a><br>";
  } 
In for each statement, it generates 2 values to the $yonlen, the outputs is

Download
Download


It echos 2 links. I want to make string equals to the latest value in for each statement. How to do that ?
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 06-29-2010, 03:00 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

That's hard to say without either seeing a copy of the array it's running off of, or the php that builds the data (and even then the data is probably still necessary).
delayedinsanity is offline  
Reply With Quote
Old 06-29-2010, 03:10 PM   #3 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Default

Ok, is there anyway to make number to the beginning of the values in for each statement ?

If 2 values echoed,

1 - Download
2 - Download

if 3 values echoed,

1 - Download
2 - Download
3- Download

?
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 06-29-2010, 03:32 PM   #4 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

I have tried out your code sample and it works good for me with a mockup array

php Code:
<?php

$testarr = array();
$testarr[] = array("url" => "http://trying.com");
$testarr[] = array("url" => "http://trying1.com");
$testarr[] = array("url" => "http://trying2.com");
$testarr[] = array("url" => "http://trying3.com");
$testarr[] = array("url" => "http://trying4.com");
$testarr[] = array("url" => "http://trying5.com");

if(isset($testarr[0]['url'])) {
  foreach($testarr as $video) {
    $yonlen = $video['url'];
    echo "<a href=$yonlen>Download $yonlen</a></br>";
  }
}
?>

It doesn't echo it twice. Maybe if we know the structure of the array like delayedinsanity said it would be easier to help you out.
tony is offline  
Reply With Quote
Old 07-10-2010, 02:52 PM   #5 (permalink)
The Wanderer
 
Join Date: May 2010
Posts: 19
Thanks: 1
core1024 is on a distinguished road
Default

PHP Code:
$nl=0;
if(isset(
$testarr[0]['url'])) {
  foreach(
$testarr as $video) {
    
$nl++;
    
$yonlen $video['url'];
    echo 
"<a href=$yonlen>$nl - Download</a></br>";
  }

core1024 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Answer Then PHP Question codefreek The Lounge 14 07-20-2009 07:19 PM
question about ftp kritikal General 3 04-28-2008 03:21 PM
$_SERVER['REQUEST_URI'] question solistus General 4 04-01-2008 09:31 PM
Cleaning data before entering database question Killswitch General 7 12-24-2007 11:29 PM
Important Database Structure Question! AnthonyOS MySQL & Databases 5 12-20-2007 03:26 PM


All times are GMT. The time now is 02:51 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design