Title: changing url value with str_replace(), retuns &#8220;Array&#8221;
Last modified: August 19, 2016

---

# changing url value with str_replace(), retuns “Array”

 *  Resolved [paundrew](https://wordpress.org/support/users/paundrew/)
 * (@paundrew)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/changing-url-value-with-str_replace-retuns-array/)
 * I am trying to use the str_replace command to replace part of an automatically
   generated URL. The original URL is placed in custom value (‘url’). I need to 
   replace occurrences of “rtex” with “190” in the url itself. The code currently
   reads:
 * <?php $url = get_post_custom_values(“url”);
    echo str_replace(“rtex”, “190”, 
   $url);?>
 * It should be fairly simple, but I am getting a return of:
 * “Array”
 * I’m not terribly experienced with PHP, and any help much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/changing-url-value-with-str_replace-retuns-array/#post-1307920)
 * [get_post_custom_values](http://codex.wordpress.org/Function_Reference/get_post_custom_values)
   returns an array of all values stored against the key – in your case `url`. Even
   if there’s only 1 value, it will still return an array. Try something like:
 * `echo str_replace("rtex", "190", $url[0]);?>`
 *  Thread Starter [paundrew](https://wordpress.org/support/users/paundrew/)
 * (@paundrew)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/changing-url-value-with-str_replace-retuns-array/#post-1308208)
 * Great, works perfectly. I’m unfamiliar with php and little things like this can
   be tricky to work with. Thanks very much esmi.
 * Paul

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘changing url value with str_replace(), retuns “Array”’ is closed to new
replies.

 * 2 replies
 * 2 participants
 * Last reply from: [paundrew](https://wordpress.org/support/users/paundrew/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/changing-url-value-with-str_replace-retuns-array/#post-1308208)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
