Welcome Guest, Not a member yet? Register   Sign In
string parsing in between curly bracket
#3

[eluser]Reynolds[/eluser]
[quote author="Nick_MyShuitings" date="1294216509"]I'm not sure if your question is clear enough to help. Is that in a view,controller etc? Are you using a templating engine?

This php function might be what you're looking for: http://php.net/manual/en/function.sprintf.php

Code:
<?php
$format = 'The %2$s contains %1$d monkeys.
           That\'s a nice %2$s full of %1$d monkeys.';
printf($format, $num, $location);
?>
[/quote]


my bad, what I meant was...

In mysql, I have table named items

|ITEM_ID|ITEM_NAME|ITEM_PRICE|



In CI controller, I have a method-- I want to replace those that requests an item information, and replace it with whatever in the mysql-table above. This replaced string is then passed to a view.

My thinking is similar to CI's templating, except that it should be just implemented as a helper function, of which I just need to find those codes e.g. "{item_name:123}" and replace it with the item_id 123 from the items mysql-table.

and this function actually captures the entire html string contents, and replace whatever needs to be replaced, then return the result to the output view.

Not sure, if I stated it right, I'm a little dizzy right now, thinking as to how can I pull this :|


Messages In This Thread
string parsing in between curly bracket - by El Forum - 01-04-2011, 07:08 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 08:35 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 08:44 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 08:59 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 09:07 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 09:16 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 09:25 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 09:33 PM
string parsing in between curly bracket - by El Forum - 01-04-2011, 10:16 PM
string parsing in between curly bracket - by El Forum - 01-05-2011, 01:57 AM
string parsing in between curly bracket - by El Forum - 01-05-2011, 02:00 AM
string parsing in between curly bracket - by El Forum - 01-05-2011, 05:06 AM
string parsing in between curly bracket - by El Forum - 01-06-2011, 01:09 AM
string parsing in between curly bracket - by El Forum - 02-16-2011, 08:19 PM
string parsing in between curly bracket - by El Forum - 02-16-2011, 10:25 PM
string parsing in between curly bracket - by El Forum - 02-18-2011, 07:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB