Jump to content

Replace return value


cat250

Recommended Posts

Hello again.

 

I use echo "Rating:".$json['Rating]."/10"; and get in return:

7.5/10 - it's ok.

But I want to replace 7.5 with 75.png (image), 6.3 with 63.png, 9.4 with 94.png... hope u understand.

Know someone how I can do this? Thanks. :)

Link to comment
Share on other sites

Here's a simple example

 

<?php
$rating = "7.5/10";
$rating_number = explode("/",$rating);
$rating_number[0] = str_replace(".","",$rating_number[0]);
$image_number = $rating_number[0].".png";
echo $image_number;
?>

 

But in your case you already have value can use.

 

$image_number = $json['Rating];
$image_number = str_replace(".","",$image_number).".png";
echo $image_number;

 

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.