Reputation: 49
I am fetching a url which is stored in mysql database to a php variable.
$data_want_to_manipulate=$row['data'];
suppose the $data_want_to_manipulate
is viewarticle.php?id=121
.
from that i want to take out only 121 means what I can do?.
Upvotes: 0
Views: 79
Reputation: 159
Try this
<?php
$data_want_to_manipulate='viewarticle.php?id=121';
$str=explode('=',$data_want_to_manipulate);
echo $str[1] ; // 121
?>
Upvotes: 0
Reputation: 5166
use explode
function like this
$str=explode('=',$data_want_to_manipulate);
echo $str[1] // 121
or
echo end($str); //121
Upvotes: 0
Reputation: 2447
use this
<?php $data_want_to_manipulate1=explode('=',$data_want_to_manipulate);
echo $data_want_to_manipulate1[1];?>
Upvotes: 1