Kelvin Kelvin - 1 year ago 67
PHP Question

how to change some string based on database php

guys i have problem in change some part of string in

with this following code :

string(62) "/asset/images/menu/Singapore/365/225/509/509_RhWu2f4G_s130.jpg"

i want trying to change the
with a new string of number which i save it in

example if i have
should be like this :

string(62) "/asset/images/menu/Singapore/365/226/509/509_RhWu2f4G_s130.jpg"

guys is that possible to change that

thank you (:

Answer Source

if your data always in same position. than its simple

just explode your code first

$split=array_map('trim', explode("/",$menu_image));
$split[6] = $category_id;
$menu_image_link = implode("/",$split);

than your $menu_image_linkwill return :

string(62) "/asset/images/menu/Singapore/365/".$category_id."/509/509_RhWu2f4G_s130.jpg"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download