Results 1 to 7 of 7
-
19th Jan 2012, 08:16 AM #1OPMember
[PHP] Images Swap
Hey Guys , need some help with the code below :
$var1 = $images[0]; // Source Image
$var2 = $screens; // Screenshots
$var3 = "http://url/defaultimage.jpg";
Need a simple function to check whether $var1 = ( blank , Null , array) in which case it uses $var2 & if $var2 = ( blank , Null , array) , then it uses $var3 .
I got part of it working but still needs some work and i'm not very good with php :
$image = $var1;
if (($var1 == NULL) || ($var1 == "") || ($var1 == "Array") || (is_array($var1)))
{
$image = $var2;
}
if (($var2 == NULL) || ($var2 == "") || ($var2 == "Array") || (is_array($var2)))
{
$image = $var3;
}
viruz99 Reviewed by viruz99 on . [PHP] Images Swap Hey Guys , need some help with the code below : $var1 = $images; // Source Image $var2 = $screens; // Screenshots $var3 = "http://url/defaultimage.jpg"; Need a simple function to check whether $var1 = ( blank , Null , array) in which case it uses $var2 & if $var2 = ( blank , Null , array) , then it uses $var3 . I got part of it working but still needs some work and i'm not very good with php : Rating: 5
-
19th Jan 2012, 09:40 AM #2Respected MemberWebsite's:
DL4Everything.com Soft2050.inUse empty() : http://php.net/manual/en/function.empty.php
PHP Code:$image = "http://url/defaultimage.jpg";
if (empty($images[0]))
$image = $screens;
else
$image = $images[0];
-
19th Jan 2012, 09:43 AM #3OPMember
any way to do it for 3 parts ?
In the above case , its only for the $images[0] & the $screens
But i got 1 more as last resort for a default pic
I need it to use the $image[0] first if available , then the screens , then the default if the 2 above is not available.
-
19th Jan 2012, 09:46 AM #4Respected MemberWebsite's:
DL4Everything.com Soft2050.injust noticed i added only a else check other then else if so this one should work:
PHP Code:$defaultimage = "http://url/defaultimage.jpg";
$image = "";
if (empty($images[0])) {
if (empty($screens))
$image = $defaultimage;
else
$image = $screens;
} else {
$image = $images[0];
}
-
19th Jan 2012, 09:48 AM #5OPMember
In a few cases the $screens may not be present so it gives this error :
Notice: Undefined variable: screens in C:\xampp\htdocs\qtest.php on line 6
[img][/img]
-
19th Jan 2012, 09:51 AM #6MemberWebsite's:
imdber.org justpaste.methen use isset()
-
19th Jan 2012, 09:59 AM #7Respected MemberWebsite's:
DL4Everything.com Soft2050.inThe edited reply should work then.
Check if $images[0] is empty, If It is then it checks the same for $screens
If $screen is also empty then sets the default variable else $image = $screen
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Google+ Post +1 swap
By joshmoore in forum Traffic Market (Buy, Sell and Trade)Replies: 0Last Post: 14th Feb 2012, 01:01 AM -
Swap File
By skinner in forum Hosting DiscussionReplies: 5Last Post: 11th Jan 2012, 10:46 PM -
Like my site & I'll like yours (Facebook swap)
By solarman in forum Community CooperativeReplies: 0Last Post: 17th Sep 2011, 02:40 PM -
Swap between Alertpay and Paypal
By puharta in forum Community CooperativeReplies: 4Last Post: 5th Mar 2011, 11:12 AM -
Free images host uploader - images will not expire!
By jippo in forum Useful SitesReplies: 11Last Post: 11th Feb 2011, 11:58 PM
themaPoster - post to forums and...
Version 5.23 released. Open older version (or...