Jump to content

Ignore first 2 7 characters


CanMan2004

Recommended Posts

Hi all

I have the value

[code]$where = $rows['areaname'];[/code]

If you print [code]$where[/code], this outputs a code, which is something like

76568765-12322

or

98976528-43266

I want to do the above but ignore the first 8 characters, so for the above, it would output

-12322

or

-43266

Can this be done easily, or shall I rebuild how this is added to the database?

Any help would be great

thanks  Ed
Link to comment
https://forums.phpfreaks.com/topic/30222-ignore-first-2-7-characters/
Share on other sites

you can use the explode function.
[code=php:0]
$where = $rows['areaname'];

$split = explode("-", $where);
echo "First 8: ".$split[0]."<br> Second 5: ".$split[1];
[/code]

there is some other ways as well. but i prefer using arrays. i love my arrays. :)
There are many ways to do this, the easiest uses the function [url=http://www.php.net/substr]substr()[/url]

[code]<?php
$str = '76568765-12322';
echo substr($str,8);
?>[/code]

To ProjectFear: Your method doesn't produce the output the OP requested.

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.