Activity Stream
48,167 MEMBERS
6891 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member

    Default [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

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Use 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]; 
    No need to create extra variables

  4.     
    #3
    Member
    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.





  5.     
    #4
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    just 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];  


  6.     
    #5
    Member
    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]






  7.     
    #6
    Member
    Website's:
    imdber.org justpaste.me
    then use isset()

  8.     
    #7
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    The 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Google+ Post +1 swap
    By joshmoore in forum Traffic Market (Buy, Sell and Trade)
    Replies: 0
    Last Post: 14th Feb 2012, 01:01 AM
  2. Swap File
    By skinner in forum Hosting Discussion
    Replies: 5
    Last Post: 11th Jan 2012, 10:46 PM
  3. Like my site & I'll like yours (Facebook swap)
    By solarman in forum Community Cooperative
    Replies: 0
    Last Post: 17th Sep 2011, 02:40 PM
  4. Swap between Alertpay and Paypal
    By puharta in forum Community Cooperative
    Replies: 4
    Last Post: 5th Mar 2011, 11:12 AM
  5. Replies: 11
    Last Post: 11th Feb 2011, 11:58 PM

Tags for this Thread

BE SOCIAL