PHP » PYTHON |
login |
register |
about
|
PYTHON substr_replace
is this article helpful?
|
Python replacement for PHP's substr_replace
[
edit
| history
]
Try this one without any warranty for validity:
def substr_replace(subject,replace,start,length): if length == None: return subject[:start] + replace elif length < 0: return subject[:start] + replace + subject[length:] else: return subject[:start] + replace + subject[start+length:] substr_replace(PHP 4, PHP 5) substr_replace — Replace text within a portion of a string Descriptionsubstr_replace() replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement . Parameters
Return ValuesThe result string is returned. If string is an array then array is returned. Examples
Example #1 substr_replace() example
<?php
Notes
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|