geekish fellow
geekish fellow

Reputation: 49

how to manipulate data after retrieving from database

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

Answers (3)

Sujeet Kumar
Sujeet Kumar

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

Manoj Dhiman
Manoj Dhiman

Reputation: 5166

use explode function like this

$str=explode('=',$data_want_to_manipulate);
echo $str[1]             // 121
or 
echo end($str);           //121

Upvotes: 0

Vivek Singh
Vivek Singh

Reputation: 2447

use this

<?php $data_want_to_manipulate1=explode('=',$data_want_to_manipulate);
    echo $data_want_to_manipulate1[1];?>

Upvotes: 1

Related Questions