Danish Bhatti Danish Bhatti - 5 days ago 5
PHP Question

replace string with a db function in php

i want to replace a string with database function if it exists. i am using str_replace in following way but it doesn't work for me, this is returning $numOne as it was. i am beginner in php so help me

function stringreplace($multiple,$numOne){
$multiple=Multiply;
$numOne=a_b_cMultiply;
str_replace($multiple,"abcdfgh('','')::numeric",$numOne);
return $numOne;
}

Answer

Your code is not correct as you are not storing the result anywhere and also you are returning $numOne which contains the old value . Use this code:

function stringreplace($multiple,$numOne){
$multiple='Multiply';
 $numOne='a_b_cMultiply';
 $num_one = str_replace($multiple,"abcdfgh('','')::numeric",$numOne);
return $num_one;
}