Jump to content

How to do this please?


11Tami

Recommended Posts

Hello I'm stuck on and need help. Its going pretty well but where I'm at is below the line. My questions is, is there any way to make the arrays simpler? I studies php arrays but can't make sense of their examples. For instance with PHP can I put the array's together somehow from left to right instead from top to bottom? So instead of what I have below the line is it possible to do an array something like this?

 

$image[1] = "http://www.website.com/image1.jpg"; $link[1] = "http://www.google.com"; $title[1] = "image title 1"; 

I still need the the lines in the array numbered. Please let me know if there is a way to list the numbered arrays from left to right instead of the way I have it below. Thank you very much.

 

 

_______________________________________________
$cookie=cookie expiration code goes here.
$image  = Array(); 
$image[1] = "http://www.website.com/image1.jpg";
$image[2] = "http://www.website.com/image2.jpg";
$link  = Array(); 
$link[1] = "http://www.google.com";
$link[2] = "http://www.yahoo.com";
$title  = Array(); 
$title[1] = "image title 1";
$title[2] = "image title 2";
if (in_array(substr($image[$cookie], -3), array('jpg'))) 
$getimage = $image[$cookie];
?>

<?php
echo "<a href='$link[$cookie]'><img title='$title[$cookie]' src='$getimage' border='0'></a>"; ?>

Link to comment
Share on other sites

If I get what you mean, you want to do this:

 

$image[1] = "http://www.website.com/image1.jpg";
$image[2] = "http://www.website.com/image2.jpg";
//can also be said as:
$image = array('http://www.website.com/image1.jpg', 'http://www.website.com/image2.jpg');

//oh, also, please note that arrays start at 0, not 1, so that would make $image[0] and $image[1] set.

 

Also, this line could be done more effeciently...

 

//if (in_array(substr($image[$cookie], -3), array('jpg'))) 
if (substr($image[$cookie], -3) == 'jpg') 
$getimage = $image[$cookie];

 

 

Link to comment
Share on other sites

If that doesn't answer your question, please could you reword it? As I understand it, like corbin said, it sounds like you want to do:

 

$image = array('http://www.website.com/image1.jpg', 'http://www.website.com/image2.jpg');

 

However, there's no (feasible) way to try to join the first element of image, link and title, other than to say, use a 2d array or an object...

Link to comment
Share on other sites

after scanning the post is thsi what you want:

 

$IMAGES[1]['name'] = "";

$IMAGES[1]['URL] = ""'

$IMAGES[1]['location'] = "";

 

$IMAGES[2]['name'] = "";

$IMAGES[2]['URL] = ""'

$IMAGES[2]['location'] = "";

 

$IMAGES[3]['name'] = "";

$IMAGES[3]['URL] = ""'

$IMAGES[3]['location'] = "";

 

 

ect?

 

jsut define it like that will do yyou

 

Link to comment
Share on other sites

Thanks a lot everybody you're tops!!!

 

oi, pc nerd, I think thats it! But how do I use the name, url, location, in this following?? Please let me know, thank you very much.

 

<?php
echo "<a href='$link[$cookie]'><img title='$title[$cookie]' src='$getimage' border='0'></a>"; ?>

Link to comment
Share on other sites

I don't know how to add the second parameter of the array to the image link further below url, location, etc., the cookie expiration I can do. Can someone help me with this last piece? Thank you very much.

 

<?php
$cookie="cookie expiration here"
$image  = Array();   
$image[1]['location'] = "http://www.google.com";
$image[1]['URL'] = "http://www.website.com/1.jpg"'
$image[1]['name'] = "http://www.yahoo.com";
$image[2]['location'] = "image title 1";
$image[2]['URL'] = "http://www.website.com/2.jpg"'
$image[2]['name'] = "image title 2";
if (in_array(substr($image[$cookie], -3), array('jpg'))) 
$getimage = $image[$cookie];
?>

<?php
echo "<a href=''[$cookie]"><img title='[$cookie]' src=''[$cookie]" border='0'></a>"; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.