Jump to content

[Solved] Retrieve single line from MySQL field


aeris130

Recommended Posts

Suppose I have a field in a column (attributes) that looks like this:

 

pageclass_sfx=
back_button=
item_title=1
link_titles=
introtext=1
section=0
section_link=0
category=0
category_link=0
rating=
author=
createdate=
modifydate=
pdf=
print=
email=
keyref=

 

How can I use php to retrieve the value from a single line inside the field, given that there's a value stored at the end of the line (after '=')?

 

Are there any tutorials that deal with this specifically?

Link to comment
Share on other sites

<?php
$array = split("=", $attributes);

for ($i=0; $i<(count($array)-1); $i++) {
    $newArray[$array[$i]] = $array[($i+1)];
    $i++;
}

echo 'First element is ' . $newArray['pageclass_sfx'] . '<br />';
?>

 

Something like that?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.