th - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of th.php

  1.                 <?php
  2. $brand_terms = get_the_terms( $product->id, 'pa_brand' );
  3.  
  4. if ( $brand_terms && ! is_wp_error( $brand_terms ) ) {
  5.     $brand_slug = $brand_terms[0]->slug;
  6.  
  7.  
  8.     if ( $brand_slug ) {
  9.  
  10.         $formatted_brand = str_replace( '-', '-/-', ucwords( $brand_slug ) );
  11.  
  12.  
  13.         $formatted_brand = str_replace( 'kia', 'KIA', $formatted_brand );
  14.         
  15.         $partnumber_values = get_the_terms( $product->id, 'pa_partnumber' );
  16.  
  17.         foreach ( $partnumber_values as $partnumber_value ) {
  18.             $archive_link = get_term_link( $partnumber_value->slug, 'pa_partnumber' );
  19.             $image_url = 'https://partsouq.com/assets/PartCoverThumbnail/' . $formatted_brand . '/' . $partnumber_value->name . '-COVER.png';
  20.             
  21.  
  22.             echo '<img src="' . $image_url . '" alt="' . $partnumber_value->name . '">';
  23.         }
  24.     }
  25. }
  26. ?>
File Description
  • th
  • PHP Code
  • 07 Dec-2023
  • 846 Bytes
You can Share it: