H
|
Hertz2P 4/12/2017 |
I have a table that stores the data in a numeric value. using the following: $value = str_replace(","," ",$value); It will not put a between the values on the view page If I switch the values to characters instead numeric, the works? example: typefield data - 1,2,3 ( ID ) table column set to "varchar" this will not put a between the results in the view page if I change it word,word,word the works? Any ideas
|
M
|
mhollibush author 4/13/2017 |
Try without the quotes, numbers typically don't need them in a custom view.
|
M
|
mhollibush author 4/14/2017 |
I am confused on what you mean by try it without quotes... where?
|
Y
|
YCH 4/16/2017 |
I have tried to take the quoted out and the script errors - I am confused on why this works when there are words in the field, but it won't work with numeric values -
|
M
|
mhollibush author 4/18/2017 |
$value = str_replace(","," |
Y
|
YCH 4/18/2017 |
$value = str_replace(","," ", strval($value)); This did not work either.... This is very confusing to me. Anyone have any other suggestions?
|
M
|
mhollibush author 4/18/2017 |
Trying to help : you could try single quotes instead of double quotes: $value = '1,2,3'; // (mind the single quotes here!) $value = str_replace(',',' ', $value); // (mind the single quotes here!) versus $value = "1,2,3"; // (mind the double quotes here!) $value = str_replace(",", " ", $value); // (mind the double quotes here!) Any of these working ? Edited --> or finally $value = '1,2,3'; $search = ','; $replace = ' '; $value = str_replace( $search, $replace, $value) ;
|
![]() |
Admin 4/18/2017 |
Function str_replace, of course, works the same way with strings and numbers but there is something else involved. I assume that this field is a multi-select lookup wizard and PHPRunner treats those fields differently depending on how they setup. If Link Field and Display Field are different 'View as' Custom will be executed multiple times, once for each comma separated value. I won't be executed for the whole string like 1,4,6. This means you won't be able to replace commas with |
M
|
mhollibush author 4/18/2017 |
Function str_replace, of course, works the same way with strings and numbers but there is something else involved. I assume that this field is a multi-select lookup wizard and PHPRunner treats those fields differently depending on how they setup. If Link Field and Display Field are different 'View as' Custom will be executed multiple times, once for each comma separated value. I won't be executed for the whole string like 1,4,6. This means you won't be able to replace commas with using 'View as' Custom. Luckily there is a simple workaround, you just need to move your code to another event. On the List page you can use BeforeRecordProcessed event: https://xlinesoft.com/phprunner/docs/before_record_processed.htm
|