Jump to content

[SOLVED] populate array help


dusoo

Recommended Posts

Hi guys,

could you please help me to populate one array with data from oracle table column?

And later i would like to match one string with that array

 

//query:

$mquery= "select column from TMP_TAB where keycol=asdf";

//parse query

$conn->query($mquery,true);

$rows = $conn->row_cnt();

echo "$rows"; //Works for me until here.

 

//I have tried to use following lines from one script, but could not get it working to populate my array...

//Maybe it is even not needed for my case.

for($lj=0; $lj < $rows; $lj++) {

//$my_array[???] = $conn->data($lj,0);

}

 

//here i would like to match one string with that array  -  in_array is good for that?

//Because i dont want to go through that array again in loop if possible.

if (in_array($my_string,$my_array)) {

echo "more code will come here";

}

Thanks guys,

sorry for my simple knowledge of PHP. ...

Link to comment
https://forums.phpfreaks.com/topic/149356-solved-populate-array-help/
Share on other sites

Does this get you any further?

 

<?php
$my_array = array();
$my_string = "foo";
$mquery= "select column from TMP_TAB where keycol=asdf";

$conn->query($mquery,true);
$rows = $conn->row_cnt();

for($lj=0; $lj < $rows; $lj++) {
    $my_array[] = $conn->data($lj,0);
}

if (in_array($my_string,$my_array)) {
    echo "more code will come here";
}
?>

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.