Advertisement
Sheriziya

Get $key and $value from artist array

Feb 10th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. <?php
  2. if ($dragon_breed != '')
  3. {
  4.     // First, let's see what $dragon_breed contains
  5. var_dump($dragon_breed);
  6.     echo "<BR>";
  7.     // That displayed the ID of the breed. Now let's get the name of the breed.
  8.     $breedid = $dragon_breed;
  9.     $breeddata = new Pod('breeds', $breedid);
  10.     echo 'Breed: ' . $breeddata->display('name') . "<BR>";
  11.     // Name of the breed is being displayed, now let's get the name of the artist with a simple display
  12.     echo 'Artist name: ' . $breeddata->display('artist') . "<BR>";
  13.     // With the above I will be screwed once I enter the link part, so let's test in another way: First get field then echo the $
  14.     $dragon_artist = $breeddata->get_field('artist');
  15.     echo 'Artist name: ' . $dragon_artist . "<BR>";
  16.     // This gives an array. Now let's see if we can get the artist id from this array. First let's get the $key and $value and see what those are.
  17.    if ($dragon_artist != '')
  18.    {
  19.    var_dump($dragon_artist);
  20.     echo "<BR>";
  21.     if (is_array($dragon_artist))
  22.     {
  23.       foreach ($dragon_artist as $key => $value)
  24.       {
  25.         echo 'Key: ' . $key . ' Value: ' . $value . "<BR>";
  26.       }
  27.     } else if (!is_array($dragon_artist))
  28.     {
  29.         echo $dragon_artist;
  30.         echo "<BR>";
  31.     }
  32.    }
  33. }
  34.  
  35.             ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement