J
J
John2016-01-28 18:19:37
PHP
John, 2016-01-28 18:19:37

How to replace characters in a string?

there is a line:

<?php
$text = "qw_er00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
echo strlen($text); //223

?>

how do I do it:
I get text in $_GET['text'], it can be 10 characters or 100 characters,
you need to take text from the $text variable and overwrite the text that came from $_GET['text'] into
it, it should come out here as follows:
the text that we received -> qq_test2016 - 11 characters (the text of which is obtained can contain up to 200 characters)
text of which is: -> qw_er00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - 223 characters
need to put together what would happen like this:
qq_test201600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 // 223 characters
ie replace, if the word is given more then, respectively, and will be replaced with zeros on!
help me decide this! Thank you!
answer:
$input = "id_alien";
$text_send = str_pad($input, 223, "0"); 
var_dump($text_send);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2016-01-28
@john_notebook

php.net/manual/en/function.str-pad.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question