user7715632
user7715632

Reputation:

How can I display all the characters after 20 characters in a string using PHP?

For example, in the string given below:

$string = "adadadadadadadadaadadadadadadadadadadadadadadadadadadadadadadadadadadadadaddadadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafewgewrehrejrejreerj";

I would like the output to consist of all the characters except the first 20. How do I achieve this?

Upvotes: 1

Views: 518

Answers (6)

Vikram Barnwal
Vikram Barnwal

Reputation: 47

if you have to only print string then you can direct echo / print . echo "your string";

Upvotes: 0

Tarun modi
Tarun modi

Reputation: 1050

Here is the code:

$string = "adadadadadadadadaadadadadadadadadadadadadadadadadadadadadadadadadadadadadaddadadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafewgewrehrejrejreerj";

echo substr($string, 20)

And check output.

Upvotes: 3

Jeruson
Jeruson

Reputation: 115

You can use the substr($string, $start)

You can see the manual here http://php.net/manual/en/function.substr.php

Upvotes: 0

ScaisEdge
ScaisEdge

Reputation: 133380

If you need the right part of the string after the 20th character you could use substr

$string = "adadadadadadadadaadadadadadadadadadadadadadadadadadadadadadadadadadadadadaddadadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafewgewrehrejrejreerj";
$rest = substr($string, 20, -1); 

see this for ref http://php.net/manual/en/function.substr.php

Upvotes: 0

Rahul
Rahul

Reputation: 18567

Here is the code,

echo substr($string, 20);

Documentation link of substr which states Return part of a string depends on your requirement.

Upvotes: 2

jacobdo
jacobdo

Reputation: 1615

$twentieth_char = substr($string, 19, 1);

Upvotes: -1

Related Questions