fn.database.php - db_str_replace function

I only stumbled upon this code because I was in fn.catalog.php in the function fn_get_product_data() looking at the statement that gets the data from the database for the product_data variable. Line of code in fn_get_product_data:

$product_data = db_get_row("SELECT $field_list FROM ?:products LEFT JOIN ?:product_prices ON ?:product_prices.product_id = ?:products.product_id AND ?:product_prices.lower_limit = 1 ?p LEFT JOIN ?:product_descriptions ON ?:product_descriptions.product_id = ?:products.product_id AND ?:product_descriptions.lang_code = [B][COLOR="Red"]?s ?p[/COLOR][/B] WHERE ?:products.product_id = ?i GROUP BY ?:products.product_id", $price_usergroup, $lang_code, $join, $product_id);

I wanted to know what the [COLOR=“Red”]RED[/COLOR] ‘?p’ and ‘?s’ shorthand was that CS-Cart was using in their mysql queries was, so I looked for the function that declared these. It was back in fn.database.php delcared in db_process() here:

} elseif ($ph == '?s') { // string
$pattern =[COLOR="Red"][B] db_str_replace[/B][/COLOR]($ph, "'" . addslashes($data[$k]) . "'", $pattern, $offset);


} elseif ($ph == '?p') { // prepared statement
$pattern = [B][COLOR="Red"]db_str_replace[/COLOR][/B]($ph, $data[$k], $pattern, $offset);

In my fn.database.php there is a function db_str_replace:

function db_str_replace($needle, $replacement, $subject, &$offset)
$pos = strpos($subject, $needle, $offset);
[B][COLOR="Red"]$offset = $pos + strlen($replacement);[/COLOR][/B]
return substr_replace($subject, $replacement, $pos, 2);

What’s the deal with the red line of code?? From what I can tell, it doesn’t do anything because the line above it uses $offset to say where in the string $subject to start looking for $needle. Then in the red line $offset is set to $pos + length of the replacement string for seemingly no reason considering the next line is a return statement that does not use the new $offset value, and then that’s it… the function is over. So it seems like the new value of the $offset isn’t even used. Am I missing something here?? What is this line even doing?

thanks for any help.