Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Can I combine the values in the database with an comma (,) instead of next line?
Topper Offline
Junior Member
**
Posts: 8
Joined: May 2012
Post: #1
Can I combine the values in the database with an comma (,) instead of next line?
Can I combine the values in the database with an comma (,) instead of next line?

Cause I am using the following code to check in PHP if one thread match with another thread:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

$id1 = '1,2,3,4,5,6,7,8,9,10'; // the values from thread_field_data where tid=1
$id2 = '10,11,12,13,14,15,16'; // the values from thread_field_data where tid=2

// splitting them up into an array
$one = explode(',', $id1);
$two = explode(',', $id2);

// making the check
$result = count(array_intersect($one, $two));
if($result > 0) {
    echo 'Something matched!';
}

?>


I don't know how to do that with newlines?

06-05-2012 08:51 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Can I combine the values in the database with an comma (,) instead of next line?
Use \n in double-quotes to represent a newline in PHP, eg

PHP Code:
$one = explode("\n", $id1);


My Blog
06-05-2012 11:17 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: