-6

I had this code

$loop ="5";
$value = "1";

how to insert value to db like this 1:1:1:1:1 (where loop have 5)

thanks

6

1 Answer 1

-1
string $val_for_Db = "";
for ($i=0;$i<$loop;$i++) {
$val_for_Db = $val_for_Db."".$value.":";
}
$val_for_Db = substr($val_for_Db ,-1);

Now insert $val_for_Db to database.

Sign up to request clarification or add additional context in comments.

2 Comments

Please avoid answering bad questions
Welcome to StackOverflow, your new but please take the time to read through this in order to ask better questions. We do not write code for you we help with specific problems. stackoverflow.com/help/how-to-ask

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.